Is there an easy way to return the SQL format for a Date?

Barry G. Sumpter BarrySum at BigPond.Net.AU
Sat Jul 14 18:10:39 CDT 2007


Hi all,

I'm looking for a way to return a date in yyyy-mm-dd format.
I think its called SQL format.

I'm using this:

SELECT 
concat(Year(T1.StartDate), '-', 
LPad(Month(T1.StartDate),2,'0'), '-', 
LPad(Day(T1.StartDate),2,'0'))
FROM T1

Which returns:  1900-09-01
Instead of: 1900-9-1


This gets quite complex if you have 4 or 5 date fields.

Is there an easier way?

Something like: 

SELECT 
format(T1.StartDate, 'yyyy-mm-dd') as myDate
FROM T1



All the best.

     Barry G. Sumpter




More information about the Valentina mailing list