Solved

# Date calculation

Posted on 2003-03-14
Medium Priority
173 Views
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
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
• 2

LVL 6

Accepted Solution

marconovaro earned 80 total points
ID: 8136677

Use the DateDiff function:

DateDiff("d", firstDate, secondDate )

M
0

LVL 33

Expert Comment

ID: 8136706
Try this

Dim mydate As Date
Dim newdate As Date

mydate = #19/06/2003#
MsgBox newdate

hongjun
0

LVL 33

Expert Comment

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

hongjun
0

LVL 1

Expert Comment

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

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