Convert date time to below format SQL Server -


i tried obtain date in format: '05-31-2014 01:20:25 am'

i used below code: sql fiddle here, output date strangely changed different date: 30-26-2011 01:30:38 am

select format(cast('2011-11-26 01:30:38.000' datetime), 'mm-dd-yyyy hh:mm:ss tt') 

sql fiddle here

when using format() function, mm minutes, mm month, change to:

select format(cast('2011-11-26 01:30:38.000' datetime), 'mm-dd-yyyy hh:mm:ss tt') 

if there's appropriate format available via convert(), preferable performs better format() function.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -