Reputation: 3322
Right now, I know of 3 ways to return the time:
CONVERT(varchar, Date, 8)
CONVERT(varchar, Date, 108)
CONVERT(time, Date)
What is the difference between #1 and #2, since they return the same answer?
Why does #3 return something that looks different--is it still equivalent to #1/#2's output?
Are there more ways?
Thanks!
Upvotes: 1
Views: 66
Reputation: 238246
Have a look at the MSDN page for convert. The format 8
is hh:mi:ss
. If you add 100
to a format, it uses a four-digit year instead of a two digit year. Since format 8
is a time format, 8
and 108
have the same output.
The third option converts a datetime
to a time
. A time
is not a string and has no format. It's up to the client how it will be displayed, typically using your local computer's Regional and Language Settings.
Upvotes: 6