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
 SQL Server Development (2000)
 DATE - DATE

Author  Topic 

itay1978
Starting Member

1 Post

Posted - 2004-09-23 : 17:35:06
i have two datetime fields.

how can i do some query that will give me the results
for date1 - date2?

Thanks

nr
SQLTeam MVY

12543 Posts

Posted - 2004-09-23 : 17:42:28
select date1 - date2 from tbl
willl work

Or was that not really the question


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

sabirpatel
Starting Member

22 Posts

Posted - 2004-09-24 : 01:22:26
Hi,


DATEDIFF( ) Calculates an interval between two dates.

eg.
SELECT fname, lname, hire_date
FROM employee
WHERE DATEDIFF(year, hire_date, getdate()) > 5

Locates all employees hired more than five years ago.

Hope this answers your question.

Regards




Sabir Patel
email: sabirpatel@gmail.com
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-09-24 : 04:02:55
Hooray! Someone else who likes to use the descriptive name for the first parameter in DATEDIFF / DATEADD

Kristen
Go to Top of Page
   

- Advertisement -