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
 get date between

Author  Topic 

Msandlana
Starting Member

33 Posts

Posted - 2008-02-12 : 03:41:57
Hi All
I want anyone that could help me with the query to select the sales that start from last year 2007, march up to the end of january this year 2008.
It would be easy If I have the full date.
you would say WHERE DATE BETWEEN '2007/03/01' AND '2008/01/31' But
I only have the Year int, Month int

eg:
Select * from Runtot_MenuName_Month
Where ?
I tried so many times but I can't get the correct results

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-02-12 : 03:45:40
use the function here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=22339 to create a datetime value



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-12 : 03:54:02
You have two column of datatype INT, one for YEAR and one for MONTH?

SELECT *
FROM Table1
WHERE 100 * YEAR + MONTH BETWEEN 200703 AND 200801



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-02-12 : 03:57:43
Oh . . . i read it as the Year int and Month int as input value


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-12 : 03:59:54
It is still possible. OP is not that clear in his problem description.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

Msandlana
Starting Member

33 Posts

Posted - 2008-02-12 : 04:07:22
Thank You very much peso its working
Go to Top of Page
   

- Advertisement -