473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Date comparison quirk?

Hi,

I had a script set up to create a redirect until a certain date, and I
left the script in there after that date thinking it would just be
dormant until I changed the date parameters.

To my surprise, it started redirecting again. I must not be clear on how
dates work.

Here is the very simple code:

<%
if date < "8/20/2005" then
response.redirect(url)
end if
%>

So why does it think that 10/10/2005 < 8/20/2005 ? What am I missing?

Thanks.
Oct 10 '05 #1
4 2413
"Byron" <sp*******@dorrk.com> wrote in message
news:MP************************@newshost.allthenew sgroups.com...
Hi,

I had a script set up to create a redirect until a certain date, and I
left the script in there after that date thinking it would just be
dormant until I changed the date parameters.

To my surprise, it started redirecting again. I must not be clear on how
dates work.

Here is the very simple code:

<%
if date < "8/20/2005" then
response.redirect(url)
end if
%>

So why does it think that 10/10/2005 < 8/20/2005 ? What am I missing?

Thanks.


It's treating them as strings.

Try: if date < DateValue("8/20/2005") then
Oct 10 '05 #2
McKirahan wrote on 11 okt 2005 in
"Byron" <sp*******@dorrk.com> wrote in message
Here is the very simple code:

<%
if date < "8/20/2005" then
response.redirect(url)
end if
%>
So why does it think that 10/10/2005 < 8/20/2005 ? What am I missing?


It's treating them as strings.
Try: if date < DateValue("8/20/2005") then


and then only if you are sure your server's regional settings
are set on the expected [foreign to me = states side] date
representation, otherwize DateValue("8/9/2005") could mean
either 8 september or 9 august.

Better be sure codewize [meaning not depending on settings
outside your code] and use:

if date < DateValue("2005/8/20") then

or:

if date < DateValue("August 20, 2005") then

or [if a code litteral] use the short version:

if date < #2005/8/20# then
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 11 '05 #3
I'd suggest changing this:
if date < "8/20/2005" then

To be this:
if date < DateSerial(2005, 8, 20) then

Best regards,
J. Paul Schmidt, Freelance Web and Database Developer
http://www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips

*** Sent via Developersdex http://www.developersdex.com ***
Oct 17 '05 #4

Byron wrote:
Hi,

I had a script set up to create a redirect until a certain date, and I
left the script in there after that date thinking it would just be
dormant until I changed the date parameters.

To my surprise, it started redirecting again. I must not be clear on how
dates work.

Here is the very simple code:

<%
if date < "8/20/2005" then
response.redirect(url)
end if
%>

So why does it think that 10/10/2005 < 8/20/2005 ? What am I missing?


Use DateDiff function

http://msdn.microsoft.com/library/de...ctdatediff.asp

Oct 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Donnal Walter | last post by:
I was very surprised to discover that >>> import datetime >>> x = datetime.date(2004, 9, 14) >>> y = datetime.datetime(2004, 9, 14, 6, 43, 15) >>> print x == y True How can these two...
2
by: Scott Knapp | last post by:
Good Day - I have a form which sets the current date, as follows: <script type="text/javascript"> xx=new Date() dd=xx.getDate() mm=xx.getMonth()+1 yy=xx.getYear() mmddyy=mm+"/"+dd+"/"+yy...
16
by: KL | last post by:
I am working on a problem and desperately need help! I need to prompt a user for the numerical month of birth, day of birth and year of birth and store it in varialbes and the use the variables...
3
by: Karl Gibbon | last post by:
Hi There, I currently have a database in Access 2002 with several forms. I would like to restrict access to one form in perticular until November 1st every year. My current method (attempted...
6
by: MarkAurit | last post by:
Im having difficulty coming up with a good algorithm to express the following comparison: "if <a given date> falls between the (current date - 5 days) and the (current date)" Obviously....
3
by: Tiya | last post by:
Hi there !!! I would like to know how to compare dates in javascript. var sdate = new Date(theform.SubmissionDate.value); var odate = new Date(theform.StartDate.value); var todaysdate = new...
4
by: blini | last post by:
Helo.... How I can convert string "26/03/2006 15:51" for a date? I need to convert and to compare if "09/06/2006 14:20" is lesser or equal that the current date. Everything in Javascript.
1
by: nickdahat | last post by:
OK, here's the quirk I have. I'm building a scheduler for a Fire Truck Manufacturing company. They have like 8 date fields per truck to be built. If they have to squeeze in a truck between...
4
by: anagai | last post by:
I just want to check if a date entered in a textbox is equal to the current system date. I set the date object from the input field like this: dt1=new Date('10/01/2007'); the current system...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.