Ye Myat Aung
Ye Myat Aung

Reputation: 1853

Convert Time in SQL not to have millisecond

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

Answers (1)

Mikael Eriksson
Mikael Eriksson

Reputation: 138960

You can convert to DATE and TIME(0).

CONVERT(DATE, [timeStamp]) AS date, CONVERT(TIME(0), [timeStamp]) AS time

Upvotes: 38

Related Questions