?
Solved

Date calculation

Posted on 2003-03-14
4
Medium Priority
?
173 Views
Last Modified: 2010-05-01
I have a date calculation. How do you calculate any two dates (but in the same year) to find the number of days. The date format is: DD/MM/YYYY. For example, 19/06/2003 - 23/04/2003. And How do you add on nine months (in the format: DD/MM/YYYY) to a date to get the accurate date?

An accurate date must be given, i.e. need to take into account that some months have different number of days.

0
Comment
Question by:Lucy168
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
marconovaro earned 80 total points
ID: 8136677

Use the DateDiff function:

DateDiff("d", firstDate, secondDate )

and use DateAdd to add months:

DateAdd("m", 9, startDate)

M
0
 
LVL 33

Expert Comment

by:hongjun
ID: 8136706
Try this

Dim mydate As Date
Dim newdate As Date

mydate = #19/06/2003#
newdate = DateAdd("m", 9, mydate)
MsgBox newdate


hongjun
0
 
LVL 33

Expert Comment

by:hongjun
ID: 8136713
OOPS. Did not see your comment before I post mine.

hongjun
0
 
LVL 1

Expert Comment

by:JH0401
ID: 8137776
With your format being DD/MM/YYYY, it might get crazy trying to get number of days between dates!  You could re-format dates in order to get accurate time frame between the dates.

You could use the following to obtain the number of days between 2 dates(If format was MM/DD/YYYY or YYYY/MM/DD)

Dim NumDays%

NumDays = format(format(Date1,"YYYY/MM/DD"),"#") - format(format(Date2,"YYYY/MM/DD"),"#")
msgbox NumDays
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question