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)
 find date month year diff

Author  Topic 

oracle_corrgi
Yak Posting Veteran

98 Posts

Posted - 2006-09-19 : 03:33:17
hi

how do i find date month year diff

thanxs


database

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-19 : 03:40:29
To what date do you want to compare? Today's date? To get current date and time, use SELECT GETDATE()
When you are used to that function, you can learn more about DATEDIFF function, to get the diff's you want. There are special considerations though.

The difference is time between 20060919 23:59:59 and 20060920 00:00:01

is, when using

second time interval: 2
minute time interval: 1
hour time interval: 1
hour day interval: 1

DATEDIFF uses the "occupied" timeslot according to the resolution you choose, when calculating the diff in time.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -