splitting a datetime column into year, month and week

前端 未结 3 1860
时光说笑
时光说笑 2021-01-12 07:24

I want to split a datetime column so that the year and the month both have their own column in a select statement output. I also want to have a column by week of the year, a

3条回答
  •  滥情空心
    2021-01-12 08:10

    check this

    select datepart(Month,DateColumn) Mnth,datename(Month,DateColumn) MnthName,datepart(Year,DateColumn) Year1,((day(DateColumn)-1) / 7) + 1 week from dbo.Table
    

提交回复
热议问题