473,396 Members | 1,792 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,396 software developers and data experts.

Advice on dates (not the lonely hearts ones)

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
4 2044
> 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
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
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
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: RelaxoRy | last post by:
So I like this girl and.. harrrranyway, I have birth dates in a table stored as 11/07/1982 or 7/5/1974 etc. Now there are 7150 records and I cannot really alter the date format to conform...
3
by: Not Me | last post by:
Hi, Not sure if this would be possible without using vba or similar programming, but can I use sql to create a column of dates in a regular sequence (such as weekly, monthly etc.) I would...
1
by: Likhith Areekkal | last post by:
Hi, Language: C#, asp .net application This is a room reservations web application. I have two Calendars on my website: Calendar1 & Calendar2 Calendar1 shows the current month and Calendar2...
3
by: MaRCeLO PeReiRA | last post by:
Hi Guys, I am in troubles with some dates. "I need to know the difference, in days, between two dates." Well, if the difference is less than a month, so I could use:
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
2
by: Elainie | last post by:
I have a requested date field which is a date, I need to create a form with start requested date and end requested date with who it was sent to...... So I need 2 date boxes in a popup form with...
1
by: mbatestblrock | last post by:
I think I have a rather advanced question that I was hoping to find some good help with. I am still pretty new to VBA and I know that doesn't help my situation here. But here is what I am trying to...
9
by: Mo | last post by:
After a little PHP education, my first project (to get my feet wet) is making an employee time-tracking program for our small business. *** ANY SUGGESTION, THOUGHTS, OR ADVICE WOULD BE WARMLY...
16
by: Prisoner at War | last post by:
They say not to use JavaScript for important things, but doesn't that mean relegating JavaScript usage to frivolous effects? It's said to consider whether it's truly necessary to use JavaScript,...
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:
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.