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 2005 Forums
 Transact-SQL (2005)
 Compare results of 2 dates into another column

Author  Topic 

rwaldron
Posting Yak Master

131 Posts

Posted - 2008-10-10 : 12:09:00
Hi all.
I have a webform that inserts dates into an SQL DB.
There is a requirement now to run reports on this data.

On Update I want to be able to compare 2 columns and update result into another column IN THE SAME TABLE..

Is this easily done..

eg: I Have 2 dates already in DB dateraised,datecomplete.
I have created anotheR column ahead of time called dateresult.
Is this as easy as going

update table set dateraised = @dateraised,datecomplete = @datecomplete, dateresult = DATEDIFF(day,dateraised,datecomplete)

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-10 : 12:51:08
just do this

update table set dateraised = @dateraised,datecomplete = @datecomplete, dateresult = DATEDIFF(day,@dateraised,@datecomplete)
Go to Top of Page
   

- Advertisement -