In this article, the date obtained by GetDate() consists of two parts, namely today's date and the time at that time: Select GetDate() Use DateName() to get the corresponding year, month, and day, and then connect them That's it:
Select Datename(year,GetDate())+'-'+Datename(month,GetDate())+'-'+Datename(day,GetDate())
In addition, DateName() can also obtain the hour, time, seconds, day of the week, and week number, as follows:
Select Datename(hour,GetDate())
Select Datename(minute,GetDate())
Select Datename(second,GetDate())
Select Datename(weekDay,GetDate())
Select Datename(week,GetDate())
What is obtained is Nvarchar type, which needs to be converted to Convert(datetime, concatenated date, 0)