holty
02-06-2003, 06:22 PM
Dates are really doing my head in!!
I have a problem running this.
SELECT Count(tblAdvert.ModelID) FROM tblAdvert WHERE tblAdvert.ModelID = 5 AND tblAdvert.Date >= '" & NOW()-14 &"'
This should count the number of adverts in the last 14 days. I thought it was working fine until we moved onto a new month - February. It won't show any adverts in the last 14 days that are in this month.
I wrote this little script to test:
<%response.write NOW()%>
<%response.write "<BR>"%>
<%response.write NOW()-14%>
<%response.write "<BR>"%>
<% if "01/02/03 09:30:48" <= NOW()-14 then
response.write "Outside the 14 days"
else
response.write "Within the 14 days"
end if
%>
It returns the current date and time and the same 14 days ago. When I tested 01/02/03 09:30:48 - it returned "Outside the 14 days"
I have tried using the datediff function. This works when i query it in Access but doesn't for some reason when i put it in my asp page.
e.g.
SELECT Count(tblAdvert.ModelID) FROM tblAdvert WHERE tblAdvert.ModelID = 5 AND DateDiff("d",tblAdvert.Date,NOW()) <= 14;
Has anyone got any ideas to count the adverts in the last 14 days? Like i said earlier it will work ok until we hit a new month
I'm confused!:(
I have a problem running this.
SELECT Count(tblAdvert.ModelID) FROM tblAdvert WHERE tblAdvert.ModelID = 5 AND tblAdvert.Date >= '" & NOW()-14 &"'
This should count the number of adverts in the last 14 days. I thought it was working fine until we moved onto a new month - February. It won't show any adverts in the last 14 days that are in this month.
I wrote this little script to test:
<%response.write NOW()%>
<%response.write "<BR>"%>
<%response.write NOW()-14%>
<%response.write "<BR>"%>
<% if "01/02/03 09:30:48" <= NOW()-14 then
response.write "Outside the 14 days"
else
response.write "Within the 14 days"
end if
%>
It returns the current date and time and the same 14 days ago. When I tested 01/02/03 09:30:48 - it returned "Outside the 14 days"
I have tried using the datediff function. This works when i query it in Access but doesn't for some reason when i put it in my asp page.
e.g.
SELECT Count(tblAdvert.ModelID) FROM tblAdvert WHERE tblAdvert.ModelID = 5 AND DateDiff("d",tblAdvert.Date,NOW()) <= 14;
Has anyone got any ideas to count the adverts in the last 14 days? Like i said earlier it will work ok until we hit a new month
I'm confused!:(