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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 query help..

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?
Go to Top of Page

karthik_padbanaban
Constraint Violating Yak Guru

263 Posts

Posted - 2009-03-11 : 10:05:26
could you post sample data?

Karthik
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-11 : 10:05:43
[code]SELECT *
FROM Table1
WHERE 100 * colYear + colMonth BETWEEN 200801 AND 200906[/code]


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

RaghaSM
Yak Posting Veteran

52 Posts

Posted - 2009-03-11 : 10:11:15
Heres the sample data:

Month Year Type No
01 2008 Tested 20
01 2008 Deployed 1
01 2008 Analyzed 15
02 2008 Tested 23
02 2008 Deployed 2
02 2008 Analyzed 23
03 2008 Tested 34
03 2008 Deployed 4
03 2008 Analyzed 24
03 2009 Tested 12
05 2008 Deployed 10
05 2008 Analyzed 22
05 2008 Tested 17
06 2008 Deployed 02
Go to Top of Page

RaghaSM
Yak Posting Veteran

52 Posts

Posted - 2009-03-11 : 10:17:44
Thanks PESO. This works.
Go to Top of Page
   

- Advertisement -