how to get a year and day of the year by using sql server

后端 未结 2 848
暗喜
暗喜 2021-01-26 05:54

how to fetch a year and day of the year using query in sql server 2008

Ex:

11:  YY (Year)
292: Day of the year .31 + 28 +31 + 30 + 31 + 30 +31 + 31 +30          


        
2条回答
  •  余生分开走
    2021-01-26 06:13

    How about

    select 
       year(thedatetime) - 2000, 
       1 + datediff(day, cast(year(thedatetime) as varchar(4)) + '0101', thedatetime)
    

提交回复
热议问题