Convert to Datetime MM/dd/yyyy HH:mm:ss in Sql Server

前端 未结 4 827
南方客
南方客 2021-02-19 00:57

How to convert given date format to MM/dd/yyyy HH:mm:ss

I tried this one below but not achieved. Can anyone help me?

SELECT CONVERT(VARCHAR(         


        
4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-19 01:59

    Declare @month as char(2)
    Declare @date as char(2)
    Declare @year as char(4)
    declare @time as char(8)
    declare @customdate as varchar(20)
    
    set @month = MONTH(GetDate());
    set @date = Day(GetDate());
    set @year = year(GetDate());
    
    set @customdate= @month+'/'+@date+'/'+@year+' '+ CONVERT(varchar(8), GETDATE(),108);
    print(@customdate)
    

提交回复
热议问题