How to insert dates using datetime functions.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lawrence Pereira
    New Member
    • Jul 2008
    • 1

    How to insert dates using datetime functions.

    Can any one help me in inserting any date into the table using insert command
    because when i m trying to insert date using insert command the query executes but the date is totally wrong if i am inserting 6/29/1982 as date the output i get is 1900-01-01 00:00:00.000; and if i change it to 06- 29-1982 then the output comes right, I want to insert date using a gui application so what should be the format,,,,,,
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    I presume that you are putting the query into a string variable in your fromt end.
    Be sure to wrap the date up in its own quotes.

    str="Update tbl set dte='06/29/2007' where key=1"

    without the single quotes I thinke it would be treated as the mathematical expression
    6 divided by 29 divided by 2007 which is close enough to 0
    if you set a date filed to the number 0 you get the date
    01-01-1900 00:00:00
    The beginning of time according to microsoft

    PS
    I cannot explain why your second version worked
    I would have thought it would be treated as a mathematical expression also ??

    Comment

    Working...