Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread Formatting date in expression
Wed, Mar 5 2008 2:41 PMPermanent 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 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Uli


You'll have to use your current approach or write a UDF.

Roy Lambert
Thu, Mar 6 2008 5:05 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email 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 PMPermanent 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 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate 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 AMPermanent 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 SmileThanks.

Uli
Fri, Mar 7 2008 10:32 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email 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 AMPermanent 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

Image