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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calculating a date range 1

Status
Not open for further replies.

jwdcfdeveloper

Programmer
Mar 20, 2001
170
US
I am looking for a piece of code or insight on how to write something that can determine the start date and end date for a given week of the month. For instance, if I select today's date (6/30/2005). I should have two numbers returned 26 and 30 (representing Sunday 6/26 and Thursday 6/30), where July 1st and 2nd aren't included because they are not part of the month, though they are part of the week. If anyone has a theory on how to build this (I'd like to encapsulate this function in a CFC) function/CFC, I'd appreciate it.
 
You'll need to set variables for Month(Now()), DaysinMonth(Year(Now()),Month(Now()),1), DayofWeek(Now()). You'll need to calculate for each day of the week to count back to Sunday and subtract that many days from the current date. Then count ahead to Saturday and add that many days to the current date. Then you'll need to compare the date you come up with for Saturday to see if it's in the current month and if not display your DaysinMonth variable. You may also need to do a similar process for Sunday if that were to fall in the previous month.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top