Getting week number of date in SQL

前端 未结 6 1387
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-23 08:26

Is there a way to get the week number of a date with SQL that is database independent?

For example to get the month of a date I use:

SELECT EXTRACT(MONTH         


        
6条回答
  •  心在旅途
    2021-01-23 09:06

    select (DATEPART(yyyy , CAST(GETDATE() AS datetime)) * 100 + 
            DATEPART(ww , CAST(GETDATE() AS datetime))) as week
    

提交回复
热议问题