Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SMALLDATETIME CONVERSION PROBLEM

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-24 : 08:52:26
Manoj writes "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

I'm using SQL Server7

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"

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-07-24 : 09:12:45
SET @vCmd = 'UPDATE ' + @vTableName + ' SET locked = 0 , lockedby = ''' + @vUserName + ''', lastupdated = '''+ CONVERT(CHAR(25),GETDATE(),103) + ''' WHERE ' + @vFieldName +' IN (' + @vFieldValue +')'
EXEC (@vCmd)

<O>
Go to Top of Page
   

- Advertisement -