user240141
user240141

Reputation:

Compare today with some value passed from front end

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.

Upvotes: 0

Views: 72

Answers (2)

Sam
Sam

Reputation: 7678

You can retrieve parts of the date with DATEPART.

DATEPART ( datepart , date )

DATEPART( MM, GETDATE())

Should return an INT value of 3 for March.

Upvotes: 1

Thorsten Dittmar
Thorsten Dittmar

Reputation: 56707

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?

Upvotes: 0

Related Questions