public static DateTime DateFromWeek(
int year,
int week,
DayOfWeek dow,
int offset
)
Public Shared Function DateFromWeek (
year As Integer,
week As Integer,
dow As DayOfWeek,
offset As Integer
) As DateTime
public:
static DateTime DateFromWeek(
int year,
int week,
DayOfWeek dow,
int offset
)
static member DateFromWeek :
year : int *
week : int *
dow : DayOfWeek *
offset : int -> DateTime
A week is defined as a seven day period starting on the specified day of the week. The first week of the year is defined as the one starting on the specified day of the week and containing at least four days of the year.
If the year starts on a day of the week later than the one specified, this may return a date a few days earlier than January 1st of the specified year for week 1.
Not all years will have a 53rd week. For example, assuming a Monday week start, week 53 can only occur when Thursday is January 1st or if it is a leap year and Wednesday is January 1st. It is up to the caller to determine this and discard the date. WeeksInYear(Int32, DayOfWeek) can be used to determine this condition.
// Returns Monday 12/29/1997 because 01/01/1998 falls on a Thursday
dtDate = DateUtils.DateFromWeek(1998, 1, DayOfWeek.Monday, 0);
// Returns 08/27/2003
dtDate = DateUtils.DateFromWeek(2003, 35, DayOfWeek.Wednesday, 0);
' Returns Monday 12/29/1997 because 01/01/1998 falls on a Thursday
dtDate = DateUtils.DateFromWeek(1998, 1, DayOfWeek.Monday, 0)
' Returns 08/27/2003
dtDate = DateUtils.DateFromWeek(2003, 35, DayOfWeek.Wednesday, 0)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
ArgumentOutOfRangeException | An exception is thrown if the week value is not between 1 and 53. |