Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Week numbers and dates

Status
Not open for further replies.

Timkins

MIS
Feb 24, 2003
2
0
0
GB
Hi,
Is there any way I can get the date of the first day of the week from the week number and year?

Timkins
 
You will find a good solution to this on the Crystal Decisions website.
 
This will give you the Monday for a Year and Week.

1. Create 2 number parameters for your year and Week numbers

2. Create the Following Formula

//@MondayWeek

Local NumberVar yr := {?YearParam};
Local NumberVar wk := {?WeekParam};

Local DateVar jan1 := CDate (yr, 1, 1);
Local DateVar firstMondayOfYear := jan1 + (8 - DayOfWeek (jan1, crMonday)) mod 7;
//weekNumberOfFirstMonday is either 1 or 2
Local NumberVar weekNumberOfFirstMonday := DatePart ("ww", firstMondayOfYear, crMonday, crFirstFourDays);

DateAdd ("ww", wk - weekNumberOfFirstMonday, firstMondayOfYear) Gary Parker
Systems Support Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top