Subject | There is a way to format datetime directly in SQL ? |
---|---|
Author | hamacker |
Post date | 2012-05-15T19:31:45Z |
Hi everybody,
There is a way to format a datetime inside a query ?
When use a CAST function to convert datetime to string :
CAST(SUBSTRING(CAST(a.LAST_UPDATE as varchar(30)) FROM 1 FOR 10) <-
Get only date, without a time.
From this cast, returning date in format YYYY-MM-DD, but I would like
to see DD-MM-YYYY for concatenate purpose.
Of curse that I can use SUBSTRING to get day, month and year
separately, but its too long to be written.
Today I prefer change this format (and concatenation) inside my client
application, but if exists some function to easy format directly on
server I would like to know.
There is a way to format a datetime inside a query ?
When use a CAST function to convert datetime to string :
CAST(SUBSTRING(CAST(a.LAST_UPDATE as varchar(30)) FROM 1 FOR 10) <-
Get only date, without a time.
From this cast, returning date in format YYYY-MM-DD, but I would like
to see DD-MM-YYYY for concatenate purpose.
Of curse that I can use SUBSTRING to get day, month and year
separately, but its too long to be written.
Today I prefer change this format (and concatenation) inside my client
application, but if exists some function to easy format directly on
server I would like to know.