Reputation: 76
I have a query selecting time in the format where the time column is of the DateTime datatype.
SELECT ul.time FROM user_logins;
It is returning the result in this format-
11/27/2021 9:29:46 AM
11/23/2021 12:48:20 PM
Now I want it to return in the 24 hour format like
11/27/2021 9:29:46
11/23/2021 00:48:20
Is there any possible way to achieve that?
Upvotes: 0
Views: 154
Reputation: 54
DATETIME values always stored in 24 hour format. As your column defined as DATETIME datatype, it's in 24 hour format
Output of DATETIME datatype:
2021-12-07 18:21:30.907
AM / PM is not mentioned by DATETIME, So We can format it.
Query: Select CONVERT(varchar,GETDATE(),9)
Output: Dec 7 2021 7:26:55:077PM
Upvotes: 1