Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / November 2007

Tip: Looking for answers? Try searching our database.

New to DateDiff Function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bwojcik - 30 Nov 2007 15:19 GMT
I am trying to create a database in Access using a Table.  I'm trying to set
the DateDiff function to calculate the Last Day Worked and Now for every
entry.  How and where do I enter with information.
Michel Walsh - 30 Nov 2007 15:36 GMT
If you need the two dates, side by side, in a singe row, you need to refer
to the table twice, though a join, as example.

SELECT a.dateWork, b.dateWord,
       LAST(a.someOtherField),
       LAST(b.againSomeOtherField)

FROM (myTable AS a LEFT JOIN myTable As b  ON a.dateWork > b.dateWork)
                                      LEFT JOIN myTable AS c  ON a.dateWork
> c.dateWork

GROUP BY a.dateWork, b.dateWork

HAVING Nz(b.dateWork = MAX(c.dateWork), true)

Note that I used outer join since the very earliest date won't have any
'previous date'. As it is, anything you will refer through the alias b could
be seen as data relevant to the working date before the data you can access
through alias a.

dateWork            Event
2001.01.05        "Nothing"
2001.01.06        "Again, nothing
2001.01.12        "Now, something""

should, with

SELECT a.dateWork, b.dateWork, LAST(a.event), LAST(b.event) FROM ...

produce

2001.01.05            null                nothing                   null
2001.01.06       2001.01.05       again nothing        nothing
2001.01.12       2001.01.06       now something    again nothing

Hoping it may help
Vanderghast, Access MVP

>I am trying to create a database in Access using a Table.  I'm trying to
>set
> the DateDiff function to calculate the Last Day Worked and Now for every
> entry.  How and where do I enter with information.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.