Advice on dates (not the lonely hearts ones)

Ask a Question related to ASP, Design and Development.

  1. #1

    Default 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




    Laphan Guest

  2. Similar Questions and Discussions

    1. SQL Statement BETWEEN 2 Dates - Advice Please.
      strList = "select * " _ & "from tbltest "_ & "WHERE user LIKE '%" & Replace(strSearch, "'", "''") & "%' AND ID < '2' "_ & "AND IDate Between...
    2. Dates again
      Hello all I'm having trouble getting iis to understand the UK format of dates ASP off a MS Access database I have the following query:...
    3. Dates
      Thanks to all those who replied. I ended up doing some research myself and found a good date module at...
    4. Help with Dates please
      Hi, In a SQL table I have a field named departure and a date in inserted in it. What is the exact syntax to get only records with a future date...
    5. WIreless Network, Lonely Computer
      Two wireless networks, one home, one office. Both using same SSID name. Both have two other computers on the network, besides this Dell Inspiron...
  3. #2

    Default Re: Advice on dates (not the lonely hearts ones)

    > 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.


    Aaron Bertrand - MVP Guest

  4. #3

    Default Re: Advice on dates (not the lonely hearts ones)

    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" <aaron@TRASHaspfaq.com> wrote in message
    news:OcBooHrjDHA.360@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.
    >
    >

    Hannibal Guest

  5. #4

    Default Re: Advice on dates (not the lonely hearts ones)

    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 <Dominique@webadstudio.com> wrote in message
    news:#KeJGUxjDHA.2312@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" <aaron@TRASHaspfaq.com> wrote in message
    news:OcBooHrjDHA.360@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.
    >
    >



    Laphan Guest

  6. #5

    Default Re: Advice on dates (not the lonely hearts ones)

    > 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.


    Aaron Bertrand - MVP Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139