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 |
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2009-04-02 : 23:35:07
|
i have a table where the customer date is storedas month colomn and year colomni mean month march is 3 april 4 and so oncustomerid customername month year1 john 3 20073 james 5 20075 jane 1 20087 jack 4 2008if i want the information between the dates '03/01/2007' and '04/01/2008' how can i write the select query using the month and year coloumn |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2009-04-02 : 23:58:06
|
SELECT * FROM myTable WHERE CONVERT(datetime, CAST([month] as varchar) + '/01/' + CAST([year] as varchar), 101) BETWEEN '03/01/2007' AND '04/01/2008'Warning: not tested, and the convert function may bomb on months less than 10. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|