By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,985 Members | 2,884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,985 IT Pros & Developers. It's quick & easy.

Advice on dates (not the lonely hearts ones)

P: n/a
Hi All

Have a couple of quandaries that I was wondering if you could assist on:

1) Created a page whereby the user selects the day, month and year from 3
separate pop-ups rather than all the rigmarole of checking what kind of date
they enter in 1 text box. My quandary here is that there is going to be a
smart alec (probably a brown noser who wants to take my client away from me)
who'll select something like 31 April 2003 from the pop-ups, which will
obviously make the system blow a gasket as it tries to file this incorrect
date.

Has anybody thought of a good way to trap this without a load of JavaScript
whatsits?

I was thinking of checking the month and if the day was over 30 for month
x,y,z then fix it to 30 before I file it to the DB. Best way?

2) I have setup a system where news messages are given an expiry date so
that when they are older than today's date they aren't displayed on the
site.

My problem is that even though I thought my syntax of:

IF MyDateVar < Now() THEN
don't display it
ELSE
display
END IF

was OK, if MyDateVar is the same date as Now() it's still classing it as
expired even though my test clearly shows that it is testing if it is less
than today (ie, Now).

Bizarre or what??

If you are kind enough to reply, could you please post in the NG rather than
my email address, as I have 'fudged' it to stop bogus MS viruses.

Rgds

Laphan


Jul 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
> I was thinking of checking the month and if the day was over 30 for month
x,y,z then fix it to 30 before I file it to the DB. Best way?
NO.

Then you have to deal with February (28 days, and sometimes 29). Use a date
object, and use the VBScript isDate() function once the date has been
submitted to the server. Instead of massaging the data for them and make it
work by picking the closest valid date, return an error message and tell
them to stop being a smart alec. They might even learn something new about
our calendar.
2) I have setup a system where news messages are given an expiry date so
that when they are older than today's date they aren't displayed on the
site.

My problem is that even though I thought my syntax of:

IF MyDateVar < Now() THEN
Are you pulling ALL of the data back from the database, and then looping
through ALL of the data, and checking EVERY single row to make sure it meets
some criteria? You might, maybe, consider putting a WHERE clause on your
SQL statement. Assuming an index on the datetime column, this will make
your database happier, will make your network usage increasingly more
efficient than it will be in the current scheme (since the data, assumedly,
is growing), and will completely eliminate any need to check the data before
displaying it. Only pull data that you *need*... it is a total waste to ask
for the whole year when all you care about is today.
was OK, if MyDateVar is the same date as Now() it's still classing it as
expired even though my test clearly shows that it is testing if it is less
than today (ie, Now).

Bizarre or what??
No, this is not bizarre. I'm assuming MyDateVar is something like
'2003-10-09 04:35:00 PM'. Guess what? Now() is '2003-10-09 06:06:00 PM'...
which is greater? Maybe you meant to use Date() instead of Now().
If you are kind enough to reply, could you please post in the NG rather than my email address, as I have 'fudged' it to stop bogus MS viruses.


Yep, that's the way peer-to-peer forums work; post here, read here.
Jul 19 '05 #2

P: n/a
for the smartass:
just use a client-side vbscript check for the date

if not isDate(myDate) then
msgBox "Ur a smartAss!!"
end if

oh, and yeah...

NOW() and Today are not the same :-)
Today happened before NOW() hehehhe....

"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:Oc*************@TK2MSFTNGP12.phx.gbl...
I was thinking of checking the month and if the day was over 30 for month x,y,z then fix it to 30 before I file it to the DB. Best way?
NO.

Then you have to deal with February (28 days, and sometimes 29). Use a

date object, and use the VBScript isDate() function once the date has been
submitted to the server. Instead of massaging the data for them and make it work by picking the closest valid date, return an error message and tell
them to stop being a smart alec. They might even learn something new about our calendar.
2) I have setup a system where news messages are given an expiry date so
that when they are older than today's date they aren't displayed on the
site.

My problem is that even though I thought my syntax of:

IF MyDateVar < Now() THEN
Are you pulling ALL of the data back from the database, and then looping
through ALL of the data, and checking EVERY single row to make sure it

meets some criteria? You might, maybe, consider putting a WHERE clause on your
SQL statement. Assuming an index on the datetime column, this will make
your database happier, will make your network usage increasingly more
efficient than it will be in the current scheme (since the data, assumedly, is growing), and will completely eliminate any need to check the data before displaying it. Only pull data that you *need*... it is a total waste to ask for the whole year when all you care about is today.
was OK, if MyDateVar is the same date as Now() it's still classing it as
expired even though my test clearly shows that it is testing if it is less than today (ie, Now).

Bizarre or what??
No, this is not bizarre. I'm assuming MyDateVar is something like
'2003-10-09 04:35:00 PM'. Guess what? Now() is '2003-10-09 06:06:00

PM'... which is greater? Maybe you meant to use Date() instead of Now().
If you are kind enough to reply, could you please post in the NG rather

than
my email address, as I have 'fudged' it to stop bogus MS viruses.


Yep, that's the way peer-to-peer forums work; post here, read here.

Jul 19 '05 #3

P: n/a
HI Aaron/Hannibal

Many thanks for invaluable advice. As always, all your pointers did the
trick.

Best Regards

Laphan

PS: Aaron, I knew you'd crack that special paging thing. Just as a matter
of interest is it possible to create the same thing in Access or is it too
complex a procedure??


Hannibal <Do*******@webadstudio.com> wrote in message
news:#K**************@TK2MSFTNGP12.phx.gbl...
for the smartass:
just use a client-side vbscript check for the date

if not isDate(myDate) then
msgBox "Ur a smartAss!!"
end if

oh, and yeah...

NOW() and Today are not the same :-)
Today happened before NOW() hehehhe....

"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:Oc*************@TK2MSFTNGP12.phx.gbl...
I was thinking of checking the month and if the day was over 30 for month x,y,z then fix it to 30 before I file it to the DB. Best way?
NO.

Then you have to deal with February (28 days, and sometimes 29). Use a

date object, and use the VBScript isDate() function once the date has been
submitted to the server. Instead of massaging the data for them and make it work by picking the closest valid date, return an error message and tell
them to stop being a smart alec. They might even learn something new about our calendar.
2) I have setup a system where news messages are given an expiry date so
that when they are older than today's date they aren't displayed on the
site.

My problem is that even though I thought my syntax of:

IF MyDateVar < Now() THEN
Are you pulling ALL of the data back from the database, and then looping
through ALL of the data, and checking EVERY single row to make sure it

meets some criteria? You might, maybe, consider putting a WHERE clause on your
SQL statement. Assuming an index on the datetime column, this will make
your database happier, will make your network usage increasingly more
efficient than it will be in the current scheme (since the data, assumedly, is growing), and will completely eliminate any need to check the data before displaying it. Only pull data that you *need*... it is a total waste to ask for the whole year when all you care about is today.
was OK, if MyDateVar is the same date as Now() it's still classing it as
expired even though my test clearly shows that it is testing if it is less than today (ie, Now).

Bizarre or what??
No, this is not bizarre. I'm assuming MyDateVar is something like
'2003-10-09 04:35:00 PM'. Guess what? Now() is '2003-10-09 06:06:00

PM'... which is greater? Maybe you meant to use Date() instead of Now().
If you are kind enough to reply, could you please post in the NG rather

than
my email address, as I have 'fudged' it to stop bogus MS viruses.


Yep, that's the way peer-to-peer forums work; post here, read here.



Jul 19 '05 #4

P: n/a
> PS: Aaron, I knew you'd crack that special paging thing. Just as a matter
of interest is it possible to create the same thing in Access or is it too
complex a procedure??


It uses temp tables, so no, I don't think it would be trivial to duplicate
in Access. You might consider using MSDE.

However, having said that, you could certainly pull all the rows into a
disconnected recordset and organize them that way in ASP. Won't be quite as
efficient or elegant, but it could be done.
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.