December 7, 2016 at 1:38 pm
Hi
Having a problem trying to figure out formatting a datettime as "mm/dd/yyyy h:mm:ss AM/PM"
Any help would be great!!
Thanks
December 7, 2016 at 2:08 pm
There's no direct code, but this should help.
DECLARE @Datetime datetime = GETDATE();
SELECT @Datetime, CONVERT(char(10), @Datetime,101) + STUFF( SUBSTRING( CONVERT(char(100), @Datetime,109), 12, 15), 10, 4, ' ');
December 7, 2016 at 2:23 pm
jbalbo (12/7/2016)
HiHaving a problem trying to figure out formatting a datettime as "mm/dd/yyyy h:mm:ss AM/PM"
Any help would be great!!
Thanks
datetime fields do not have a format, because they need to be language and locale neutral. A format is applied by the client application. You'll either need to set the datetime format in your client application or convert your datetime field to a string.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
December 8, 2016 at 10:23 am
Thanks !!!!
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply