Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 8 of 8 total |
Formatting date in expression |
Wed, Mar 5 2008 2:41 PM | Permanent Link |
Uli Becker | Is there an easy way to format a date (German format) within an expression?
I want this result: Patient: Gail Mazen, geb. 6.2.1976 from name, given Name and birthday ... or have I to use something like this (which actually works): select 'Patient: ' + Vorname + ' ' + Name + ', geb. ' + Cast(extract(Day from Gebdat) as VarChar(2)) + '.' + Cast(extract(Month from Gebdat) as VarChar(2)) +'.' + Cast(extract(Year from Gebdat) as VarChar(4)) from Patienten; Regards Uli |
Thu, Mar 6 2008 4:12 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Uli
You'll have to use your current approach or write a UDF. Roy Lambert |
Thu, Mar 6 2008 5:05 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Uli,
<< Is there an easy way to format a date (German format) within an expression? >> We have this on our list of minor enhancements for 2.0, but for now you'll have to just write a function to do so. -- Tim Young Elevate Software www.elevatesoft.com |
Thu, Mar 6 2008 7:18 PM | Permanent Link |
Uli Becker | Tim,
<< We have this on our list of minor enhancements for 2.0, but for now you'll have to just write a function to do so. >> Thanks. Still learning the basics of EDB: can you give me a small example how to use a function within an SQL-expression. I didn't find it in the manuals. Uli |
Fri, Mar 7 2008 3:47 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Uli
Once you've got your function working and linked in you just call it like MyDateFormat(Gebdat) as a column in the sql. Writing it, for what you want could be either sql or Delphi, but since you already have the sql code you could just move that into a function Roy Lambert |
Fri, Mar 7 2008 4:59 AM | Permanent Link |
Uli Becker | Roy,
<< Once you've got your function working and linked in you just call it like MyDateFormat(Gebdat) >> Didn't know that it's that easy Thanks. Uli |
Fri, Mar 7 2008 10:32 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Uli,
<< Thanks. Still learning the basics of EDB: can you give me a small example how to use a function within an SQL-expression. I didn't find it in the manuals. >> Sure, just define the function like this: CREATE FUNCTION "FormatDate" (IN "InDate" DATE) RETURNS VARCHAR(10) COLLATE ANSI BEGIN RETURN CAST(EXTRACT(DAY FROM InDate) as VARCHAR(2)) + '.' + CAST(EXTRACT(MONTH FROM InDate) as VARCHAR(2)) + '.' + CAST(EXTRACT(YEAR FROM InDate) as VARCHAR(4)); END And then just use it in an SQL statement like a normal function: SELECT FormatDate(MyDateColumn) AS GermanDate FROM MyTable -- Tim Young Elevate Software www.elevatesoft.com |
Fri, Mar 7 2008 10:57 AM | Permanent Link |
"Uli Becker" | Tim,
> CREATE FUNCTION "FormatDate" (IN "InDate" DATE) > RETURNS VARCHAR(10) COLLATE ANSI > BEGIN > RETURN CAST(EXTRACT(DAY FROM InDate) as VARCHAR(2)) + '.' + > CAST(EXTRACT(MONTH FROM InDate) as VARCHAR(2)) + '.' + > CAST(EXTRACT(YEAR FROM InDate) as VARCHAR(4)); > END Great. Thank you! Uli |
This web page was last updated on Sunday, May 5, 2024 at 07:30 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |