Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Date Formatting Question
Sun, May 31 2015 8:28 AMPermanent Link

Cfguy

Hi,

I understand that using the command #CURRENTDATE# will insert the current date into text, however I am wondering if there is a way (or command) to specify the format of the inserted current date - e.g. suppose I want the current date to always be inserted in the format YYYY-MM-DD?

Any help with this would be greatly appreciated.

Thanks,
Cfguy
Sun, May 31 2015 11:01 AMPermanent Link

Raul

Team Elevate Team Elevate

On 5/31/2015 8:28 AM, Cfguy wrote:
> I understand that using the command #CURRENTDATE# will insert the current date into text, however I am wondering if there is a way (or command) to specify the format of the inserted current date - e.g. suppose I want the current date to always be inserted in the format YYYY-MM-DD?
> Any help with this would be greatly appreciated.

I'm not aware of the #CURRENTDATE# - where did you read about this one ?

There is however a function called CURRENT_DATE which returns a EDB date
type which already is in IS0 8601 foramt (YYYY-MM-DD for date).

For storing the date in the table you need to use the EDB format or it
would not be a valid date value so don't reformat.

However if you need to store date in a text field (varchar, clob etc) or
simply to display it in a different format then  you can use CAST
function to do so - for example :

"CAST (<myfatefield> as Varchar(10))" will return "YYYY-MM-DD"

and if you need something else you can do for example :

"CAST (<myfatefield> as Varchar(10) DATE FORMAT 'YYYY/MM/DD')"

Raul
Image