本文介紹了如何使用 SQL Server 與當前周進行比較?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
如何將 SQL Server 日期列與當前周進行比較?
How do I compare an SQL Server date column against the current week?
例如:
WHERE [Order].SubmittedDate = *THIS WEEK*
推薦答案
您可以將日期轉(zhuǎn)換為周數(shù),并將其與當前日期的周數(shù)進行比較.同樣,您還需要比較年份,以免獲得去年的周數(shù).
You could convert your date to a week number and compare this to the week number from the current date. Likewise, you'll need to compare the year as well, so that you don't get last year's weeks.
WHERE DATEPART(wk, [Order].SubmittedDate) = DATEPART(wk, GETDATE())
AND DATEPART(yy, [Order].SubmittedDate) = DATEPART(yy, GETDATE())
這篇關(guān)于如何使用 SQL Server 與當前周進行比較?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!