How to create a Date in SQL Server given the Day, Month and Year as Integers

后端 未结 7 781
误落风尘
误落风尘 2020-12-05 12:22

FOR Example if I have:

DECLARE @Day int = 25
DECLARE @Month int  = 10 
DECLARE @Year int = 2016

I want to return

2016-10-2         


        
7条回答
  •  鱼传尺愫
    2020-12-05 13:08

    select convert(varchar(11), transfer_date, 106)

    got me my desired result of date formatted as 07 Mar 2018

    My column 'transfer_date' is a datetime type column and I am using SQL Server 2017 on azure

提交回复
热议问题