Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ravivr24
Starting Member
4 Posts |
Posted - 2008-07-09 : 07:34:05
|
| I am using c# as an application and i want to extract the sales order from june 20 2005 - june 20 2006.but in my database the field is called Sales date so i wanted to have the query which shows the sales orders which were done between these dates..i tried this statement but it didnt work:select * from salesorder where sales date < june20 2006 and sales date > june 20 2005 ...it didnt work well..u guys got any suggestions thanks.... |
|
|
tfountain
Constraint Violating Yak Guru
491 Posts |
Posted - 2008-07-09 : 10:01:49
|
| You have two options. You can use the equality comparison as you have in your example or you can use the BETWEEN keyword (check out the BOL). However, in either situation you will need to either have the dates enclosed by single quotes or stored in variables and use the variables in your query.select * from salesorder where sales date < '06/20/2006' and sales date > '06/20/2005'select * from salesorder where sales date between '06/20/2005' and '06/20/2006' |
 |
|
|
|
|
|