Reputation: 1853
I have a datetime
column in my table but I need to separate it into date and time so here's what I've done so far.
CONVERT(VARCHAR(10), [timeStamp], 103) AS date, CONVERT(TIME, [timestamp]) AS time
But the problem is, I'm having milliseconds in the time column (eg. 23:39:55.0000000) so how can I do to have just hour:minute:second only?
Upvotes: 12
Views: 26913
Reputation: 138960
You can convert to DATE
and TIME(0)
.
CONVERT(DATE, [timeStamp]) AS date, CONVERT(TIME(0), [timeStamp]) AS time
Upvotes: 38