I have a datetime field which has a value like this 5/11/2010 12:04:20 PM
.... I am converting this field convert(varchar, dbo.Clients.CreatedDate,103) as CreatedDate
and i get the result as 11/5/2010
..... But how to get 11/5/2010 12:04 PM
.....
views:
38answers:
1
A:
You can use a different formatting style to include the time component.
For example:
convert(varchar, dbo.Clients.CreatedDate, 131)
All styles are documented here:
Ben Hoffstein
2010-05-12 17:07:37
@Ben `28/05/1431 12:04:20:000PM` i dont want sec and millisec
Pandiya Chendur
2010-05-12 17:09:56
Sorry, that's a different calendar system anyhow. Best solution then may be either to use a canonical format (120) or split up the date into parts (using the DATEPART) function and cast each to a separate varchar in your desired order.
Ben Hoffstein
2010-05-12 17:15:51