Access Date Functions

This page gives a brief description of the most useful date functions in Microsoft Access. You can use these functions in VBA code or as expressions in a query. Access Help gives more details than we can include here and will describe exactly how these functions operate in your version of Access.

Note that functions are always followed by a pair of brackets even if - as with the Date() function - there's nothing in between them. The VBA editor in Access will sometimes remove these brackets but by entering them you are telling Access that you are attempting to use a function.

Remember that a date or a datetime in Access is wrapped in # symbols - for example: #28/02/2000#.

Date() Gives today's date. Date$() gives the date as a string. There is also a Date command which sets the system date.
Day(<date>) Returns the day of the month (1 .. 31) of <date>.
DateAdd(<interval>,<number>,<date>) Adds an interval to <date>. These intervals can be anything from seconds to years depending on the value of the <interval> parameter.
DateDiff(<interval>, <date1>, <date2>) Subtracts <date2> from <date1> and gives the result in the units specified by the <interval> parameter. Uses the same codes for <interval> as DateAdd() above.
DatePart(<interval>, <datetime>) Extracts a part of <datetime>, for example the minute, week or quarter.
Format(<datetime>, <format>) Returns <datetime> as a string of text in the format specified.
Hour(<time>) Returns the hour of <time> as a number from 0 to 23. Note that midnight is 00:00 and that means that midnight "tonight" is actually tomorrow.
Minute(<time>) Returns the minute of <time> as a number from 0 to 59.
Month(<date>) Returns the month number of <date>.
Now() Returns the current date and time from the system clock.
Second(<time>) Returns the seconds component of <time> as a number from 0 to 59.
Time() Returns the current time. The Time$() function gives it as a string. There is also a Time command which sets the system time.
WeekDay(<date>) Gives the day of the week as a number from 1 to 7.
Year(<date>) Returns the year number of <date>.

Other functions

Access logical functions

Access numeric functions

Access text functions

MS Access Tips

Visual FoxPro Tips

General Tips

 

Related Items

Alvechurch Data - Custom Database Development and Training

Alvechurch Data are based close to Birmingham and provide Microsoft Access and Visual FoxPro training courses. We also develop and support VFP and Access databases.

Read More

Custom Toolbars

Your Access database will look more impressive if you add custom toolbars.

Read More

Development Services

Alvechurch Data specialise in Microsoft Access and FoxPro databases. Based in Worcestershire, we have fifteen years experience developing systems for small business use.

Read More

Access and Visual FoxPro Training

Microsoft Access and Visual FoxPro training courses and workshops offered by Alvechurch Data in Worcestershire.

Read More

Support Services

How Alvechurch Data can help you with maintenance and support of your Access and Visual FoxPro databases.

Read More