|
-
June 9th, 2008, 07:49 AM
#1
find 6th working day
Any ideas on how I can find the 6th working day of each month?
I don't want to put in a check for if Monday, else if Tuesday advance 1 day, etc. although maybe this is the only way?
-
June 9th, 2008, 10:18 AM
#2
Re: find 6th working day
In what language are you planning to implement this? If PHP, you can easily do this using date() and mktime().
Pay good attention to example #1 (4th implementation) of the date() page.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
June 9th, 2008, 10:20 AM
#3
Re: find 6th working day
Yes, but date() doesn't have a built in check for working days.
I assume I am going to have to code and check the actual day:
if day == 6 and saturday or sunday then day++
then do a recursive loop until it equals monday-Friday?
-
June 9th, 2008, 10:21 AM
#4
Re: find 6th working day
EDIT: Ah, only Mon-Fri. You will have to do an if statement for that.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
June 9th, 2008, 10:31 AM
#5
Re: find 6th working day
Here is a quick implementation I just wrote up. This should work for you.
PHP Code:
<?php
function sixthDay($m, $y) {
$n = 0;
for ($d = 1; $d <= date('t', mktime(0, 0, 0, $m, 1, $y)); $d++) {
$tempDate = date('l', mktime(0, 0, 0, $m, $d, $y));
if ($tempDate !== 'Saturday' && $tempDate !== 'Sunday') {$n++;}
if ($n == 6) {break;}
}
return $tempDate;
}
echo sixthDay(6, 2008);
?>
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
June 9th, 2008, 10:32 AM
#6
Re: find 6th working day
Example #1 doesn't have any working day code in it ?
There is some working day code further down but only to find the number of working days in a month, which is a calculation...
-
June 9th, 2008, 10:32 AM
#7
Re: find 6th working day
We posted at the same time. Read my last post.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
June 9th, 2008, 10:38 AM
#8
Re: find 6th working day
Perfect. Thanks very much.
I'll make some slight alterations to get the day numbers...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|