PC Review


Reply
Thread Tools Rate Thread

calculating max/min date differences

 
 
=?Utf-8?B?TWVsaXNzYQ==?=
Guest
Posts: n/a
 
      23rd Dec 2003
I want to calculate the difference between first date in one table and last date in another table, where the records are linked by a unique case number. Does anyone know the expression I can use to do that?
Thanks so much in advance!

Melissa
 
Reply With Quote
 
 
 
 
Howard Brody
Guest
Posts: n/a
 
      23rd Dec 2003
Check the Help files for specifics and use the DMin, DMax
and DateDiff methods. Your code should look something
like this:

Dim strCaseIDVariable as String
Dim dtFirst as Date
Dim dtLast as Date
Dim intDiff as Integer

strCaseIDVariable = [ControlUsedToSelectCaseID]

dtFirst = DMin("[DateField]","tblFirstTable", _
"[CaseID]='" & strCaseIDVariable & "'")

dtLast = DMax("[DateField]","tblSecondTable", _
"[CaseID]='" & strCaseIDVariable & "'")

intDiff = DateDiff("d", dtFirst, dtLast)

and you should be able to display the difference in a
MessageBox or control:

MsgBox "This account has been active " & intDiff & " days."
OR
[txtDaysSinceLastOrder] = intDiff

Hope this helps!

Howard Brody


>-----Original Message-----
>I want to calculate the difference between first date in

one table and last date in another table, where the
records are linked by a unique case number. Does anyone
know the expression I can use to do that?
>Thanks so much in advance!
>
>Melissa
>.
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating Date AND Time Differences Lea777 Microsoft Excel Worksheet Functions 11 29th May 2006 05:15 PM
Calculating date differences in C# (DateDiff for c#??) Paul Aspinall Microsoft C# .NET 2 23rd Feb 2005 06:45 PM
Calculating date differences in C# (DateDiff for c#??) Paul Aspinall Microsoft Dot NET Framework 2 23rd Feb 2005 06:45 PM
Calculating Time and Date Differences =?Utf-8?B?RGFycmFu?= Microsoft Excel Programming 2 16th Feb 2005 01:43 PM
Calculating (Date and Time) differences Madcap Microsoft Excel Worksheet Functions 3 27th Apr 2004 11:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:51 AM.