简体   繁体   中英

Need to show date in specific format sql server

I want to show current date in following format. 9/16/2019 5:35:55 PM

select getdate()

您可以使用format()

SELECT FORMAT(getdate(), 'MM/dd/yyyy hh:mm:ss tt')
declare @Date datetime =GETDATE()
select FORMAT(@Date,'MM/dd/yyyy hh:mm:s tt') AS CurrentDate

OR

Select Convert(char(10), getdate(),101) + Right(Convert(VarChar(20),getdate(),100),8)

You can use this Query...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM