Home page
 
 Home 
 ASP 
 PHP 
 SQL 
 HTML 
 JavaScript 
 Search 
 Contact 
 
Search
or browse popular tags
Access Functions
Subscription

Sign up for the free email newsletter for new tips, tutorials and more. Enter your email address below, and then click the button.

Privacy Policy

RSS Twitter

Access: Weekday Function

Print

In Access, the Weekday function returns an integer between 1 (Sunday) and 7 (Saturday) that represents the day of the week corresponding to the date and the first day of the week provided as arguments.

The syntax for the Weekday function is:

Weekday ( date, [firstdayofweek] )

The argument date is any numeric expression that can represent a date and/or time. Numbers to the left of the decimal point in date represent the date; numbers to the right represent the time. If date is Null, this function returns a Null. The firstweekday argument is an optional integer argument that specifies the first day of the week. The following is a list of valid parameters for firstweekday.

Constant Value Description
vbUseSystem 0 Use the NLS API settings
vbSunday 1 Sunday (default used)
vbMonday 2 Monday
vbTuesday 3 Tuesday
vbWednesday 4 Wednesday
vbThursday 5 Thursday
vbFriday 6 Friday
vbSaturday 7 Saturday

Examples

Weekday (#17/07/2005#,vbSunday)      returns 1
Weekday (#17/07/2005#,4)             returns 5
Weekday (#17/07/2005#)               returns 1

VBA Code

Dim MyWeekday As Integer 
MyWeekday = Weekday(#04/12/1997#,4)

This example uses the Weekday function to obtain the day of the week from a specified date. Now the MyWeekday variable would contain the value of 4.

SQL query

You can also use the Weekday function in a query.

SELECT Weekday(#14/02/2005#,1) AS Expr1
FROM Orders


If you'd like to see how it works, enter SQL statement and press Execute
 




Tags:

Add To: Add to dzone dzone | Digg this digg | Add to del.icio.us del.icio.us | Stumble it stumbleupon

  • Comments





Copyright © 2005-2014             www.WebCheatSheet.com All Rights Reserved.