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.

difference between date/time

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dplove - 06 Nov 2007 16:57 GMT
I have searched and found some good info but nothing is working for me.  
Please help.

I have a query that has "Received Date Time and "Opened Date Time" fields.  
Each record has a parameter in it and formatting is as follows:
m/d/y space h/m/s AM/PM.

I'm trying to calucate the difference in the two and have tried the
following expressions:
DateDiff ("d", [Received Date Time] - [Opened Date Time])
Diff: [Received Date Time] - [Opened Date time]

Everything keeps coming back with no results.  What am I doing wrong?
Jerry Whittle - 06 Nov 2007 17:06 GMT
First things first: Are the fields in question date/time data types at the
table level?

Next what do you mean by "Each record has a parameter in it"? Do you mean
that each record has a value in it OR this is a parameter query that prompts
you for dates when run?

Further by "Everything keeps coming back with no results" do you mean that
no records are returned or just nothing in the calculated field?
Signature

Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

> I have searched and found some good info but nothing is working for me.  
> Please help.
[quoted text clipped - 9 lines]
>
> Everything keeps coming back with no results.  What am I doing wrong?
dplove - 06 Nov 2007 17:33 GMT
Yes, each record has a value and no records are returned.

> First things first: Are the fields in question date/time data types at the
> table level?
[quoted text clipped - 19 lines]
> >
> > Everything keeps coming back with no results.  What am I doing wrong?
Duane Hookom - 06 Nov 2007 17:55 GMT
Provide the SQL view. If you aren't returning any records then a calculated
column is not your immediate problem.
Signature

Duane Hookom
Microsoft Access MVP

> Yes, each record has a value and no records are returned.
>
[quoted text clipped - 21 lines]
> > >
> > > Everything keeps coming back with no results.  What am I doing wrong?
dplove - 06 Nov 2007 18:06 GMT
Whats the SQL View?  Sorry, I'm not a advance user.

> Provide the SQL view. If you aren't returning any records then a calculated
> column is not your immediate problem.
[quoted text clipped - 24 lines]
> > > >
> > > > Everything keeps coming back with no results.  What am I doing wrong?
croy - 06 Nov 2007 18:37 GMT
>Whats the SQL View?  Sorry, I'm not a advance user.

With your query in Design View, use the menus to go to
View|SQL View.

SQL is short for Structured Query Language.  It was
initially developed by IBM, and is used extensively in the
database industry.  It's actually what is created "under the
hood" by the query design grid in MS Access, and used to do
the real work of all your queries.

Signature

croy

fredg - 06 Nov 2007 18:09 GMT
> I have searched and found some good info but nothing is working for me.  
> Please help.
[quoted text clipped - 9 lines]
>
> Everything keeps coming back with no results.  What am I doing wrong?

Re: > Everything keeps coming back with no results.  
The above statement offers us no useful information.

Give us an example of the values in the 2 fields. What result should
be shown? What value is being shown? An #Error? Nothing? An incorrect
value? What?

Did you ever read VBA help on the DateDiff function?
The arguments are specific. You need to separate the 2 values with a
comma, not instruct Access to subtract one from the other. Access
knows that.

TimeDifference:DateDiff ("d", [Received Date Time],[Opened Date Time])

will determine, in days,  the difference between the 2 values.
Note: the above will return a value of 1 day even if the [Received
Date Time] is 11/6/2007 11:59:59 PM and the [Opened DateTime] is
11/7/2007 12:00:01 AM, just 2 seconds later, because the date boundary
has been changed.
Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Michel Walsh - 06 Nov 2007 18:11 GMT
You use a - while a coma is needed.  Use

DateDiff ("d", [Received Date Time] , [Opened Date Time])

instead of your initial syntax:

DateDiff ("d", [Received Date Time] - [Opened Date Time])

Vanderghast, Access MVP

>I have searched and found some good info but nothing is working for me.
> Please help.
[quoted text clipped - 9 lines]
>
> Everything keeps coming back with no results.  What am I doing wrong?
dplove - 06 Nov 2007 18:59 GMT
I tried
DateDiff ("d", [Received Date Time] , [Opened Date Time]) & also
DateDiff ("m" , [Received Date Time] , [Opened Date Time])

and I still get no records returning after running the query.  Here is an
example:

Received Date Time                 Opened Date Time                  
09/17/2007 15:49:24 PM          09/17/2007 3:55:24 PM                    
09/20/2007 09:55:00 AM          09/20/2007 11:48:00 AM
09/20/2007 14:40:33 PM          09/24/2007 2:40:33 PM

> You use a - while a coma is needed.  Use
>
[quoted text clipped - 19 lines]
> >
> > Everything keeps coming back with no results.  What am I doing wrong?
John W. Vinson - 06 Nov 2007 19:14 GMT
>I tried
>DateDiff ("d", [Received Date Time] , [Opened Date Time]) & also
[quoted text clipped - 7 lines]
>09/20/2007 09:55:00 AM          09/20/2007 11:48:00 AM
>09/20/2007 14:40:33 PM          09/24/2007 2:40:33 PM

This will return 0 in all instances. DateDiff("d", ...) returns the number of
passages through midnight between the dates; "m" returns the number of
passages into a new Month. If you want miNutes use "n".

It's not clear just what result you want!

            John W. Vinson [MVP]
dplove - 06 Nov 2007 19:26 GMT
The result I'm looking for is the lapse time between received and opened,
whether its minutes hours or days.   I made a mistake and typed M and I
really typed N.  No records are returning.

> >I tried
> >DateDiff ("d", [Received Date Time] , [Opened Date Time]) & also
[quoted text clipped - 15 lines]
>
>              John W. Vinson [MVP]
dplove - 06 Nov 2007 19:21 GMT
Here is my SQL view:
SELECT Lagtime.[Received Date Time], Lagtime.[Opened Date Time],
Lagtime.[Time Between Received and Opened], Lagtime.[Resolution Date],
Lagtime.[Closed Date Time], Lagtime.[Elapsed Time], Lagtime.[Department
Name], Lagtime.[(EA) Plant], Lagtime.[(EA) Floor], Lagtime.[Category
Description], Lagtime.[Module Description], Lagtime.[Source Description],
Lagtime.Status
FROM Lagtime;

> I tried
> DateDiff ("d", [Received Date Time] , [Opened Date Time]) & also
[quoted text clipped - 31 lines]
> > >
> > > Everything keeps coming back with no results.  What am I doing wrong?
Duane Hookom - 06 Nov 2007 19:32 GMT
Is Lagtime a table? Does it have any records in it?

It looks like Lagtime is a query that doesn't return any records. If it is a
query, what is the SQL view of Lagtime?

Signature

Duane Hookom
Microsoft Access MVP

> Here is my SQL view:
> SELECT Lagtime.[Received Date Time], Lagtime.[Opened Date Time],
[quoted text clipped - 40 lines]
> > > >
> > > > Everything keeps coming back with no results.  What am I doing wrong?
Duane Hookom - 06 Nov 2007 19:33 GMT
I have a feeling that you are placing the DateDiff() expression in the
criteria rather than creating a new column. Your SQL view should clear this
up.
Signature

Duane Hookom
Microsoft Access MVP

> Here is my SQL view:
> SELECT Lagtime.[Received Date Time], Lagtime.[Opened Date Time],
[quoted text clipped - 40 lines]
> > > >
> > > > Everything keeps coming back with no results.  What am I doing wrong?
dplove - 06 Nov 2007 20:06 GMT
What interval do I use if I want the results to consist of days and minutes?  
Can I use "d", "n"?

All this time I forgot to put the expression in a new column, sorry about
that.

> I have a feeling that you are placing the DateDiff() expression in the
> criteria rather than creating a new column. Your SQL view should clear this
[quoted text clipped - 44 lines]
> > > > >
> > > > > Everything keeps coming back with no results.  What am I doing wrong?
Duane Hookom - 06 Nov 2007 21:28 GMT
Find one interval and stick with it if you want a numeric value. It's fairly
easy to use minutes and then divide by 60 to get hours or divide by (60*24)
to get days.

Doug Steele has a versatile function that returns a string at
http://www.accessmvp.com/djsteele/Diff2Dates.html.
Signature

Duane Hookom
Microsoft Access MVP

> What interval do I use if I want the results to consist of days and minutes?  
> Can I use "d", "n"?
[quoted text clipped - 50 lines]
> > > > > >
> > > > > > Everything keeps coming back with no results.  What am I doing wrong?
 
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.