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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|