0
votes

I have 2 columns in a table Start date and EndDate , i want to enter Current date and it should compare current date with start and end date if current date exist between start date or enddate must return that row. i have query but not good result found select * from Seasons where CONVERT (date, GETDATE()) between '@startdate' and '@Endate'

3
Are '@startdate' and '@Endate' datetime?, date? - Jayvee

3 Answers

1
votes

Try this:

SELECT * FROM seasons 
WHERE getdate() >= @startdate 
AND getdate() <= @enddate
1
votes

SELECT * FROM mytable WHERE SYSDATE() BETWEEN start_date AND end_date

0
votes

Please check whether the below code works for you.

if both the date (startdate and enddate) should match the current date then use this.

 select * from Seasons where  convert(date,startdate) = CONVERT (date, GETDATE()) and convert(date,Endate) = CONVERT (date, GETDATE()) 

if any one of the date (startdate or enddate) should match the current date then use this.

  select * from Seasons where  convert(date,startdate) = CONVERT (date, GETDATE()) or convert(date,Endate) = CONVERT (date, GETDATE())