Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating date difference

Status
Not open for further replies.

mohebk

MIS
Aug 23, 2005
139
US
Hi,
Trying to calculate the difference between two date fields in mm/dd/yyyy format. Can I use Sale_Rate: Sale_Date - Receive_Date? I am doing that but I am getting some wierd numbers.

Thanks


Mo
 
Look for "DateDiff Function" in the VBA help file

________________________________________________________
Zameer Abdulla
Help to find Missing people
Seek counsel of him who makes you weep, and not of him who makes you laugh.
 
Mo,
Did you try use DateDiff() (note the spelling)?
Your original expression should work. What do you mean by "I am getting some wierd numbers"? Dates are stored as floating point numbers so it is legimate to subtract one date from another date.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
That is what I thought too. I thought I know access pretty well. I am getting larger numbers than expected and some numbers are negative.

Thanks for the quick reply.

Mo
 
Mo,
Maybe you should provide some sample records with the result of your calculation. I wonder if your date formatting is different from m/d/y?

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Can someone please tell me how to calculate the difference in days in MS Access? I know there is a Date_Diff function, but I am not sure how to write it in a query.
For Example: Difference in days 12/10/2005 - 1/10/2006

Thanks!
 
In the query grid:
NumberOfDays: [end date field] - [start date field]

Or:
NumberOfDays: DateDiff('d',[start date field],[end date field])

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top