开发者

Compare today with some value passed from front end

开发者 https://www.devze.com 2023-02-17 16:01 出处:网络
I need to compare current day with some value. Like from front end开发者_运维问答 I am passing 5, then in t-sql I want to match if the current day of the month is 5.You can retrieve parts of the date

I need to compare current day with some value. Like from front end开发者_运维问答 I am passing 5, then in t-sql I want to match if the current day of the month is 5.


You can retrieve parts of the date with DATEPART.

DATEPART ( datepart , date )

DATEPART( MM, GETDATE())

Should return an INT value of 3 for March.


Well, just pass an INT parameter to your stored procedure (I'm assuming you're using this in a stored procedure?). Then you can do something like

IF DATEPART(dd, CURRENT_TIMESTAMP) = @givenday ...

Does that help?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号