Date prob

  • Hi friends,

    create table Sep_92

    (

    Regno int,

    Payment datetime

    )

    insert into Sep_92 values (19,2005/12/05)

    select * from Sep_92

    i am getting this output

    1900-01-01 00:00:00.00019

    1900-01-01 00:00:00.00019

    1900-01-01 00:00:00.00019

    1900-02-03 00:00:00.000

    perfect date is not getting what i can do any body plz help me

  • Always mention the column names when inserting. In case someone decises the names have to be alfabetically sorted.

    insert into Sep_92 (Regno,Payment) values (19,'2005/12/05')

  • try this instead:  ...values (19,'2005/12/05')  (note the single-quotes around the date)

    Without quotes, SQL Server sees 2005/12/05 as 2005 ÷ 12 ÷ 5, which rounds to the integer value 33.  Your insert statement actually was this:

    insert into Sep_92 values (19,33)

    For date values, Day 0 = Jan 1, 1900, so day 33 = Feb 3, 1900.

    -Eddie

    Eddie Wuerch
    MCM: SQL

  • As a bit of a sidebar... why is it necessary to create a table named after a month and year???

    --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 4 posts - 1 through 3 (of 3 total)

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