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

后端 未结 2 839
暗喜
暗喜 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)
    
    0 讨论(0)
  • 2021-01-26 06:20
    SELECT RIGHT(YEAR(GETDATE()),2), DATEPART (DAYOFYEAR,GETDATE())
    
    0 讨论(0)
提交回复
热议问题