Friday, April 30, 2010

Determine week number based on starting date

Programmer Question

I need help to create a function to determine the week number based on these 2 parameters:




  1. Starting date

  2. Specified date



For example, if I specify April 7, 2010 as the starting date & passed April 20, 2010 as the date to lookup, I would like the function to return WEEK 2. Another example, if I set March 6, 2010 as starting date and looked up April 5, 2010 then it should return WEEK 6.



I appreciate your time and help.



=================



UPDATE



For instance:



Starting date: 3/6 - week1
Lookup date: 4/5



Week 2 starts from Mar 7-13.
Week 3 (3/14-3/20).
Week 4 (3/21-3/27). Week 5 (3/28-4/3).
So 4/5 falls under Week 6.



An idea is to use the Sunday of the starting date as the NEW* starting date. So instead of looking up 3/6, the function will use 2/28 as the starting date.



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails