A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Calculating difference between dates



 
 
Thread Tools Display Modes
  #1  
Old October 23rd, 2009, 09:31 PM posted to microsoft.public.access.forms
Chi
external usenet poster
 
Posts: 299
Default Calculating difference between dates

Hi,

I use the formula below to calculate the difference between dates.
Difference: DateDiff("d",[InitialDate],[FirstF]). It works fine and gives me
the number of dates between two days like 35. However, I would like to have a
final result that shows month and date.

Ex: 35 days will be 1 month and 5 days.

Please help
Chi

  #2  
Old October 23rd, 2009, 09:59 PM posted to microsoft.public.access.forms
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Calculating difference between dates

See whether http://www.accessmvp.com/DJSteele/Diff2Dates.html meets your
needs.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Chi" wrote in message
...
Hi,

I use the formula below to calculate the difference between dates.
Difference: DateDiff("d",[InitialDate],[FirstF]). It works fine and gives
me
the number of dates between two days like 35. However, I would like to
have a
final result that shows month and date.

Ex: 35 days will be 1 month and 5 days.

Please help
Chi



  #3  
Old October 23rd, 2009, 09:59 PM posted to microsoft.public.access.forms
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Calculating difference between dates

As far as I know, you get to (have to) do that yourself.

If you know "35" days, you could use division (divide by ?30, ?31, ?28, ??)
to get the integer number of months, then use the MOD function to get the
"remainder".

Good luck

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or psuedocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.


"Chi" wrote in message
...
Hi,

I use the formula below to calculate the difference between dates.
Difference: DateDiff("d",[InitialDate],[FirstF]). It works fine and gives
me
the number of dates between two days like 35. However, I would like to
have a
final result that shows month and date.

Ex: 35 days will be 1 month and 5 days.

Please help
Chi



  #4  
Old October 23rd, 2009, 10:33 PM posted to microsoft.public.access.forms
Mr. B[_4_]
external usenet poster
 
Posts: 171
Default Calculating difference between dates

First, to assume that "35 days will be 1 month and 5 days." is not a correct
assumption. You would need to know which month of which year, especially if
you are also going to calculate the months an days between two dates and
include February and it happened to be a leap year.

There is no simple answer to this. You can try to come up with the number
of days (just use what you are currently using). Then you will need to get
the month of the starting date and then decide what you consider to be a
month. Is it from the starting date to the same day of the next month, if so
you would need to calculate just how many days were between the two dates.
Then see if there are enough days to make another months calculation. Then
when you have deteremined the number of months, you will then need to
determine just how many days you have left over from the abve calculations.


-----
HTH
Mr. B
http://www.askdoctoraccess.com/
Doctor Access Downloads Page:
http://www.askdoctoraccess.com/DownloadPage.htm


"Chi" wrote:

Hi,

I use the formula below to calculate the difference between dates.
Difference: DateDiff("d",[InitialDate],[FirstF]). It works fine and gives me
the number of dates between two days like 35. However, I would like to have a
final result that shows month and date.

Ex: 35 days will be 1 month and 5 days.

Please help
Chi

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:13 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.