FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Brilliance requested - calculating a date next month
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Brilliance requested - calculating a date next month [message #174478 is a reply to message #174450] Mon, 13 June 2011 19:46 Go to previous messageGo to previous message
Mark Lloyd is currently offline  Mark Lloyd
Messages: 1
Registered: June 2011
Karma:
Junior Member
On Sun, 12 Jun 2011 15:05:48 -0400, bill <nobody(at)spamcop(dot)net> wrote:

> I am quietly banging my head on the wall. In concept it seems so
> simple:
>
> I need to calculate the date of an appointment next month.
> but:
> it needs to be on the same day of the month,
> eg: from the 2nd Tuesday of this month to the 2nd Tuesday of
> next month.

I handle meetings which are always on the 2nd Thursday of the month. I
have a simple way to calculate the date of next month's meeting if I
know this months'. It should work the same for Tuesdays:


1. $day_of_next_months_meeting = $day_of_this_months_meeting

2. $excess = $days_in_current_month - 28

3. $day_of_next_months_meeting -= $excess

4. if ($day_o f_next_months_meeting < 8) $day_of_next_months_meeting
+= 7 //make sure its in the second week

For example, 2nd Tuesday in June is 14

Step 1: 14
Step 2: 2 (June has 2 more days than a whole number of weeks)
Step 3: 12
Step 4: 12 (in this case, July 12 is the 2nd Tuesday)

--
Mark Lloyd
http://notstupid.us

"If God wants us to do a thing, He should make his wishes sufficiently
clear. Sensible people will wait till He has done this before paying
much attention to Him." -- Samuel Butler
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Strategic HR Summit 2011 (Jun 25, Mumbai)
Next Topic: MySQL's PASSWORD() function
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 13:33:43 GMT 2024

Total time taken to generate the page: 0.03956 seconds