serious date problem (reply cannot post response)

  • I cannot seem to respond at the original post so here is my responce for serious date problem.

    1) The user enters date as text (No control if the day is less than 13) ie. The day and month could be switched by user. (try use a calander control)

    This is how I debug

    If I cannot replicate error on test and its very urgent...

    On production copy the page(s) with a new name to the server.

    response.write the actual command string that inserts the data.

    Copy the command string and paste it into Query Analyser and execute.(Sometimes this has to be on the production server)

    You will then know where the bug in coming in - Front or Back End

    I only use production when its very urgent and I have checked all of the date formats on both the front end and back end servers. Most times you will have to tweak the date at SQL server (swop day and month)


    Andy.

  • Sukhoi,

    I can't post back to your original post, either... I did take a look at the code you posted and all I can say is ...

    Daaannnnng that's a lot of math... not sure why you went through all of that because if you save the date into a DATETIME column, the column will only accept dates.  If you need to do a check before the save to give the user some feed back, couldn't you just use the ISDATE function instead of all that math with the leap year calcs and all?

    Another thing... you mentioned that your date format is DD/MM/YYYY... did you know that the CONVERT function will also allow you to identify what the format of an input is?  For example, this works for the format you mentioned...

    SELECT CONVERT(DATETIME,'30/06/2004',103)
    ------------------------------------------------------

    2004-06-30 00:00:00.000

    (1 row(s) affected)

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply