Click here to Skip to main content
15,901,666 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi , I want to return those records which if todays date is coming between my start date and end date. Start date and end date should also be included if my todays date is anyone of that.

Please suggest sql where clause for the same
Posted
Comments
phil.o 9-Dec-15 2:09am    
Are we expected to guess your database schema?
What have you tried? Where are you stuck?
Torakami 9-Dec-15 2:22am    
select * from MarketingUpdate
WHERE CONVERT(Date,GETDATE()) BETWEEN CONVERT(date,StartDate) and CONVERT(date,EndDate)

This is what I have tried but not sure its correct or not ..
All I need is I want to check my start date and end dates have been expired or not ..meaning . if these dates are not coming between my start date and end date .. then these are old dates ..and I want to remove that
phil.o 9-Dec-15 2:27am    
Please do not post code in comments. Comments are not meant for that. Better use the "Improve question" button and qualify your question with relevant details.
And, still, we do not have the schema of your table; just the query, but we would need to your datatable types.

1 solution

Depends on the database you are using.
In SQL Server, for example, query would be
select * from tableA<br />
where tableA.col1 >= CAST(CURRENT_TIMESTAMP AS DATE)<br />
and tableA.col1 < DATEADD(DD, 1, CAST(CURRENT_TIMESTAMP AS DATE))
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900