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
 General SQL Server Forums
 New to SQL Server Programming
 Date Manipulation

Author  Topic 

rsmith904
Starting Member

1 Post

Posted - 2007-07-23 : 12:39:03
I have a table with one column as a date field in the form of mm/dd/yyyy and I would like to create a new column on a report as 'Days Open' using the column with random dates in the past and subtracting it from the current system date. Can anyone provide any assistance. I'm very new to SQL Server. I know in Oracle u can use 'sysdate'

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-23 : 12:45:57
The MS SQL Server equivalent is CURRENT_TIMESTAMP or GETDATE()


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-07-23 : 12:46:54
GetDate() will provide the current Date & Time

DateDiff(day, EarlierDateExpression, LaterDateExpression)

will provide the difference between two dates, in Days (you can use Years, Minutes, Months, Milliseconds, etc. as the first parameter)

Kristen
Go to Top of Page
   

- Advertisement -