Hi, I have found some ways on using Convert() function for SQL server. But i do not understand some of them.
Example:
CONVERT(VARCHAR(10),column name,108)
What is the 108 for? I see some with 120 and 101. I tried all but only 108 is working for me the way I want..but i do not understand what is that for actually. Can anyone explain it to me? Thank you.
Hi,
You can get the time part of a date column value as varchar by using the convert function with style 108
Say,
select top 1 ApplicationDate from Applications
returns "2003-04-11 15:20:00"
Then
SELECT top 1 CONVERT(VARCHAR(10), ApplicationDate ,108) from Applications
will return
15:20:00
For more information check BOL for CAST and CONVERT
Eralper
http://www.kodyaz.com
The style I use most often is 112, which converts a datetime to an ISO date in the format YYYYMMDD.
No comments:
Post a Comment