question

BrianHo168 avatar image
BrianHo168 asked

How to convert datetime to SQL datetime

Hi, I am sure this question was asked so many times but I am unable to locate the one with AM/PM input datetime format. Please advise. I want to convert 06/09/2015 04:30 PM or 06/09/2015 04:00 AM to SQL datetime format. Thanks,
datetime
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mjharper avatar image
mjharper answered
CONVERT should do the trick. Depending if the original date is in UK or US format you can use one of the following: SELECT CONVERT(datetime,'06/09/2015 04:30 PM', 101)--US SELECT CONVERT(datetime,'06/09/2015 04:30 PM', 103)--UK More info can be found here: [ https://msdn.microsoft.com/en-GB/library/ms187928.aspx][1] [1]: https://msdn.microsoft.com/en-GB/library/ms187928.aspx
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

BrianHo168 avatar image
BrianHo168 answered
Thank you. It works!
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.