Click here to Skip to main content
15,908,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
select * from mytable where MONTH(mydate) BETWEEN MONTH(startingdate) and MONTH(endingdate)

If i have the above statement with the following data;


SN NAME STARTINGDATE ENDINGDATE

1 BAB 03/04/2011 05/07/2012
2 ggg 16/04/2011 10/03/2012
3 hhh 34/04/2011 16/04/2012

and my mydate is 05/04/2011

the data with SN 2 will not be included, which is not suppose to be.

Please kindly help me out
Posted

I don't understand what your problem is. Besides 3 having a bad starting date (there's no day 34) all 3 starting dates are in month 4, as is mydate, so all should be included in the result set.

If you want #2 excluded because its starting date DAY is after mydate, then don't check for just the MONTH, just check the date itself.
 
Share this answer
 
v2
Are we saying there no body that can find solution to this problem? This is the third time I posted this problem without solution.

I NEED HELP BADLY
 
Share this answer
 
Walt Thanks. The correct data is;

SN NAME STARTINGDATE ENDINGDATE

1 BAB 03/04/2011 05/07/2012
2 ggg 16/04/2011 10/03/2012
3 hhh 04/04/2011 16/04/2012


if u search for a date YEAR(MONTH(05/04/2011)), ie searching for April 2011,
only data 1 and 3 will display, the data with SN 2 will not be included, which is not suppose to be. All the data supposed to display.

I need help please
 
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