Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friend

i want to find record between todays date to before 5 days. here my query but its doesn't find and reocrd

SQL
select * from OrderMaster where OrderDate between CONVERT(char(8),GETDATE(),112) and CONVERT(char(8),(GETDATE()-5),112)


is there any idea to select the record
Posted

1 solution

I'm not 100% sure but I think your parameters for your between clause are in the wrong order. If I look at the MSDN documentation:

http://msdn.microsoft.com/en-us/library/ms187922.aspx[^]

The between clause example for dates has the lowest date first, so you query would look like this:

SQL
select * from OrderMaster where OrderDate between CONVERT(char(8),(GETDATE()-5),112) and CONVERT(char(8),GETDATE(),112)
 
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