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
 Other Forums
 MS Access
 Difference between two dates.

Author  Topic 

benjamin
Starting Member

3 Posts

Posted - 2005-01-31 : 11:11:36
Hi guys,

This seems like a pretty knowledgeable forums, so hopefully someone will be able to help me! :)

I need to develop some SQL code to display the time that has occured between two dates in two fields. Basically there is a 'start date' and 'end date'(two seperate fields in the same table), added to the table to have another column/field added that can show the difference in days if at all possible!

Thanks in advance for any help!

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-01-31 : 11:18:59
select datediff(d, startDate, endDate)

Go with the flow & have fun! Else fight the flow
Go to Top of Page

benjamin
Starting Member

3 Posts

Posted - 2005-02-01 : 04:59:50
Thanks spirit, that has definately the function I am looking for. Although when I use this expression in a query using design view, I can't get it to calculate each individual set of dates (I have about 8000 start and finish dates that I need to calculate the difference between)
Go to Top of Page

benjamin
Starting Member

3 Posts

Posted - 2005-02-01 : 06:42:44
All sorted now!

This is the code used to create an extra field which shows the difference in days:

Expr1: DateDiff("d",[Learning_start_date],[MaxOfLeaving_Date])

'Learning_start_date' and 'MaxOfLeaving_Date' are the fields in the table that were used to calculate the difference in time between the two dates.



Go to Top of Page
   

- Advertisement -