SMALLDATETIME conversion problem

  • Hi Friends,

    How can I store Current date in a smalldatetime field using GETDATE() method. Through my code, it stores an unexpected date. I want to store current date & time in the table. Here is my code

    SET @vCmd = 'UPDATE ' + @vTableName + ' SET locked = 0 , lockedby = ''' + @vUserName + ''', lastupdated = '+ CONVERT(CHAR(25),GETDATE(),103) + ' WHERE ' + @vFieldName +' IN (' + @vFieldValue +')'

    EXEC (@vCmd)

    While executing the code, SQL Server stores 1900-01-01 00:00:00 in the field.

    How can I store current date

    Pls help.

    Thanks in advance

    Manoj

    P.B. No 14337

    Doha - Qatar

    Ph: 4435361

    web:www.fccqatar.com


    P.B. No 14337
    Doha - Qatar
    Ph: 4435361
    web:www.fccqatar.com

  • Try just GETDATE() and see if it works. If so then your problem may be the fact you are trying to change the dateformat and it is not being recongnized. However, it should normalkly throw and error. Either way DATEFORMAT is based on the individual user so unless the person entering the data is set for British as their default language then converting it will not work right, and if they are British then GETDATE() will return that format anyway.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

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

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