Reputation: 149
I want to show the second of the time too, not only the hours and minutes. how can i put a seconds of a time in sql code?
here's select statement:
select CONVERT(varchar(15),CAST(GETDATE() AS TIME),100)AS Currtime
here's the result:
1:48PM
expected format:
1:48:30 PM
Upvotes: 1
Views: 62
Reputation: 551
Try this
SELECT CONVERT(Varchar(10), GETDATE(),108)As CurrentTime;
or
SELECT CONVERT(TIME(0),GETDATE()) AS CurrentTime;
Result:
10:35:04
Upvotes: 1
Reputation: 7117
Try this
select RIGHT(CONVERT(VARCHAR(20),GETDATE(), 109),8) + ' ' + RIGHT(CONVERT(VARCHAR(19),GETDATE()), 2) AS Currtime
Result:
11:34:41 AM
Upvotes: 2