Date Projections
Ever wanted to know the date from given criteria, e.g the 1st Sunday in December 2003.
Try it here
Click to see versions in vb java/swing java/applet
VBScript Code
There are a number of ways to get the initial data - arguments, hard-coded, or listboxes (as above)
An example of using listboxes can be seen by viewing the source of this document.
The following code (hard-coded) will output the date for the 1st Sunday
in January 2003.
It could also be written using arguments e.g. wk = args(0),
dy = args(1) etc
Option Explicit
Dim wk,dy,mth,yr,firstOfMonth,dateRequired
wk =
1 '1 = 1st, 2 = 2nd, 3 = 3rd, 4 = 4th,
5 = Last
dy = 1 '1 = sunday,
2 = monday ... 7 = saturday
mth = 1 '1 =
january, 2 = february .... 12 = december
yr = 2003 'year
If wk = 5 Then
mth = mth + 1
wk = 0
End If
firstOfMonth = DateSerial(yr, mth,
1)
dateRequired = firstOfMonth - Weekday(firstOfMonth, (dy Mod 7) + 1) + (7
* wk)
msgbox FormatDateTime(dateRequired, vbShortdate)
back top main page vb snippets page java snippets page vbscript snippets page email Page last modified