Date and Time-Based Functions |
|
Now - Date - Time |
Microsoft Access and the Microsoft Visual Basic language are equipped with various functions used to manipulate date and time values. At the most basic level, you can use the Date(), Time(), and Now() functions to display their values. The Date() function is used to get the system date of the computer. To display the system date in a text box, you can enter =Date() in its Control Source property. The Time() function is used to get the system time of the computer. To display the system time in a text box, you can enter =Time() in its Control Source property. The Now() function combines the system date and time of the computer. |
The Day() function is used to get the numeric value that represents a day in the month. It ranges from 1 to 31 included. The syntax of the Day() function is Day(DateValue) The Month() function displays the numeric month of a date. It ranges from 1 to 12 included. The formula of the Month function is Month(DateValue) The Year() function returns the numeric year of a date. The syntax of th is function is Year(DateValue)
The DateAdd() function can be used to add an interval value, such as a number of days, weeks, months, or years to another date. Its syntax is: DateAdd(Interval, Number, date) Required, the Interval argument specifies what kind of value you want as a result. This argument will be enclosed between double quotes and can have one of the following values:
Required also, the Number argument specifies the number of units you want to add. If you set it as positive, its value will be added. If you want to subtract, pass it as a negative value. The number represents how many units of the Interval argument you want to add. The date argument is the date to which you want to add the number.
The DateDiff() function is used to find the difference between two date or time values. It allows you to find the number of seconds, minutes, hours, days, weeks, months, or years when you supply two recognizable values. The DateDiff() function takes 5 arguments, 3 are required and 2 are optional. The syntax of the DateDiff() function is DateDiff(Interval, Date1, Date2, Option1, Option2) Required, the Interval argument specifies what kind of value you want as a result. This argument will be enclosed between double quotes and can have one of the following values:
Required also, the Date1 and Date2 arguments specify the date or time values that will be used when performing the operation. By default, the days of a week are counted starting on Sunday. If you want to start counting those days on another day, pass the Option1 argument using one of the following constants: vbSunday, vbMonday, vbTuesday, vbWednesday, vbThursday, vbFriday, vbSaturday. There are other variances to that argument. If your calculation involves weeks or finding the number of weeks, by default, the weeks are counted starting January 1st. If you want to count your weeks starting at a different date, use the Option2 argument to specify where the program should start. |
|
||
Previous | Copyright © 2002-2005 FunctionX, Inc. | Next |
|