PRB: Week Starts Sunday and Ends Saturday for Format FunctionID: Q110667
|
For the date of Sunday January 2, 1994, the Format("01/02/94","ww")
function returns week number 2 instead of week number 1.
NOTE: Visual Basic handles dates according to the Country settings in the International option of the Windows Control Panel. When the Country is set to United States, dates such as "01/05/94" are by default interpreted with the month followed by the day, as in mm/dd/yy. For most other Country settings, the day precedes the month, and "05/01/94" is interpreted as dd/mm/yy.
In the Format function, weeks start on a Sunday and go through the
following Saturday. In 1994, January 1 is a Saturday, which is the only day
in week 1. Week 2 of 1994 starts on Sunday January 2.
Therefore, the Format("01/01/94","ww") function returns 1, and
Format("01/02/94","ww") returns 2.
This behavior is by design.
Below are some of the format expressions for the day, week, month, and quarter, as supported by the Format function:
dd - Displays the day as a number with a leading zero (01-31).For more information, see the Format and Format$ function topics in the Visual Basic Help menu.
ddd - Displays the day as an abbreviation (Sun-Sat).
dddd - Displays the day as a full name (Sunday-Saturday).
w - Displays the day of the week as a number (1 for Sunday through 7 for Saturday.)
ww - Displays the week of the year as a number (1-53).
m - Displays the month as a number without a leading zero (1-12). If m immediately follows h or hh, the minute rather than the month is displayed.
mm - Displays the month as a number with a leading zero (01-12). If m immediately follows h or hh, the minute rather than the month is displayed.
mmm - Displays the month as an abbreviation (Jan-Dec).
mmmm - Displays the month as a full month name (January-December).
q - Displays the quarter of the year as a number (1-4).
Sub Form_Load ()
form1.Show
Print Format("01/01/94", "ww dddd")
Print Format("01/05/94", "ww dddd")
End Sub
Additional query words:
Keywords :
Version : WINDOWS:3.0
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: May 24, 1999