dates
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Dates

Dates

resolvedResolved · Medium Priority · Version 2003

replyReply Thu 15 Jan 2009, 10:18Delegate Ann said...

Ann has attended:
Access VBA course

Dates

Is it possible to add a specified number of days to a date inserted in a field. I might for example want to initiate a prompt in the form of a message box if the calculated field (say original date + 7) is today's date.

For upcoming training course dates see: Pricing & availability

replyReply Mon 2 Feb 2009, 22:23Trainer Rajeev said...

RE: Dates

Dear Ann

Thank you for attending Access VBA course!! I hope you enjoyed the course and benefited from it.


I am not sure how comfortable you are dealing with Forms and creating calculated fields.

This answer may not be to our specific requirement so I'll just explain the general method of date calculation.

If you want a date to be calculated by adding few days to an existing field that contains a date you can simply type this command:

[field_name]+3


You can also perform the AddDate function:

The syntax for AddDate is:

DateAdd(interval, number, date)

Interval is the interval of time you want to add.

yyyy for Year
q for Quarter
m for Month
y for Day of year
d for Day
w for Weekday
ww for Week
h for Hour
n for Minute
s for Second

Note that any of these have to be entered in Inverted Commas e.g. "d"

Number is the number of intervals you want to add. E.g. if you want three days then you type 3 ensuring the first part is "d"

date is the section where you can either type any date, or you can simply type the a field in square brackets that contains a date content or if you wish to add the no. of days from today

replyReply Tue 3 Feb 2009, 12:39Delegate Ann said...

RE: Dates

Thank you for your response. This answers my question.

 

Please browse our web site to find out more about
2002 access online training and other Microsoft training courses.

Access tip:

Calculating The Difference Between Dates

If you wish to calculate the time between two date fields, this can be done in a number of ways:

1. As a calculated field in a query
2. As a calculated control in a form or report
3. As a calculation in a VBA procedure.

The basic syntax to get the number of days between two dates is:

=[One Date Field] - [Another Date Field]

You can also use one of the following functions:

=Month([One Date Field] - [Another Date Field])
which calculates the number of months between the two fields

=Year([One Date Field] - [Another Date Field])
which calculates the number of years between the two fields.

Another function is the DateDiff() function.

It uses an argument to determine how the time interval is measured. For example:

=DateDiff("q",[One Date Field] - [Another Date Field])
returns the number of quarters between the two fields.

Other intervals that can be used in this expression are as follows:
"yyyy" - Years
"m" - Months
"d" - Days
"w" - Weekdays
"ww" - Weeks
"h" - Hours
"n" - Minutes
"s" - Seconds

View all Access hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard