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 |
|
RaghaSM
Yak Posting Veteran
52 Posts |
Posted - 2009-03-11 : 09:53:18
|
| a table has month and year columns. and i want to select a data for a date range . how can i get that?suppose i want data for 01-01-08 to 06-31-09 . how should i write a query to retriv ethis?Thanks.Any help would be very much appreciated. |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-03-11 : 10:03:55
|
| The table has only months and year? what about days? And whats the datatype of the month and year fields? |
 |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
263 Posts |
Posted - 2009-03-11 : 10:05:26
|
| could you post sample data?Karthik |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-03-11 : 10:05:43
|
[code]SELECT *FROM Table1WHERE 100 * colYear + colMonth BETWEEN 200801 AND 200906[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
RaghaSM
Yak Posting Veteran
52 Posts |
Posted - 2009-03-11 : 10:11:15
|
| Heres the sample data:Month Year Type No01 2008 Tested 2001 2008 Deployed 101 2008 Analyzed 1502 2008 Tested 2302 2008 Deployed 202 2008 Analyzed 2303 2008 Tested 3403 2008 Deployed 403 2008 Analyzed 2403 2009 Tested 1205 2008 Deployed 1005 2008 Analyzed 2205 2008 Tested 1706 2008 Deployed 02 |
 |
|
|
RaghaSM
Yak Posting Veteran
52 Posts |
Posted - 2009-03-11 : 10:17:44
|
| Thanks PESO. This works. |
 |
|
|
|
|
|