var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: SQL Date Range Query
Need a little help with a Date Range query;
Im using SQL 2000 and the field is set to datetime
I need to query from now to 30 days ago, its very basic I know...
The field is called - ArtDate
Any help appreciated !
... where ArtDate >= dateadd(d,datediff(d,0,getdate()),-30)
for that, was having a moment....
I have one more if you can help please...
Date query again - need to query between two dates, but the year part is to be ignored.
Need to query between 20 March and 20 June - the year must not be queried..
What i have so far....
SELECT Title, ArtDate
WHERE (MONTH(ArtDate) BETWEEN '06' AND '09')
This will do the month query, but I need to specify start and end day as well as the month.
The year is to be ignored.
ANy help appreciated
This is tougher than it looks. Do you want to be able to query between, say, November and February, where your range overlaps two years?
Hi - i need to setup 4 queries to perford the following;
20 March to 20 June
21 June to 22 September
23 September to 21 December
22 December 19 March
Each must only query the above date range BUT NOT the year.
I have a DTS running that deletes all records that are older than 365 days.
Hope that helps ?
maybe something like this ?
(for first case)
For other ranges should change the respective values of course.
... where (month(ArtDate)=03 and day(ArtDate)>=20 )
or month(ArtDate) in (4,5)
or (month(ArtDate)=06 and day(ArtDate)<=20 )
Last edited by carloco; 08-01-06 at 12:47.
Thats perfect !
Many thanks for helping