convert varchar to datetime

  • im trying to insert a varchar value into a datetime datatype column

    '1900-00-00 00:00:00.000'

    this is a varchar because im printing out a script.

    this is what the statement looks like,but doesnt work

    INSERT INTO [AppUserStatus] ([UserID],[UserStatus],[FailedAttempts],[LockOutTime],[PwdGen])

    values(94,0,0,'1900-00-00 00:00:00.000',0)

    i've tried:

    INSERT INTO [AppUserStatus] ([UserID],[UserStatus],[FailedAttempts],[LockOutTime],[PwdGen])

    values(94,0,0,cast('1900-00-00 00:00:00.000' as datetime),0)

    i've tried:

    INSERT INTO [AppUserStatus] ([UserID],[UserStatus],[FailedAttempts],[LockOutTime],[PwdGen])

    values(94,0,0,convert(datemtime, '1900-00-00 00:00:00.000', 120),0)

    any help? need to get this working asap

  • ive sorted it out thanks:w00t:

  • I'm assuming your problem was that 1900-00-00 is not a date?

    Please let us know what the solution was in case someone else has the same problem in the future 🙂

    Thanks

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • I'm assuming your problem was that 1900-00-00 is not a date?

    Suppose the data came from MySQL as this is proprietary to them and does not port.

    brgds

    Philipp Post

    brgds

    Philipp Post

  • More reason for us to understand what fixed this, for future users

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life

Viewing 5 posts - 1 through 4 (of 4 total)

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