Jump to content

logic help for working with dates


kaydee

Recommended Posts

Hi,

 

Please assist with logic for the following.

 

Given a start date (any Monday) and no. of weeks an employee is contracted for, employee's finish date (Friday) is worked out.

(Have got it by using mysql_result(mysql_query(SELECT DATE_ADD('$start_date', INTERVAL $total_weeks * 7 - 3 DAY) AS date, 0);

 

Need to provision for Christmas break (start and finish date for the break are given), when the finish date is within the break period or after.

(start and finish date for the break period are read from the database and available within the script)

 

My question is -> How to calculate the finish date so as to make required adjustment as of the break period?

 

Thanks

 

KD

 

Link to comment
https://forums.phpfreaks.com/topic/193459-logic-help-for-working-with-dates/
Share on other sites

Can you just not add however many days the break period is on to the end of your work days? Figure out how many days the vacation time is, then when you figure your work days just add the vacation time on to it? That or use some sort of if statement and a loop, skip the days that are for vacations.

Agreed, but when to add the vacation period? The scenarios could be as below.

[*]Work start and Finish dates are before Christmas - no addition required.

[*]Start date is before Christmas and End date falls between the Christmas break - will have to add only the weeks elapsed from start of the break till Finish date

[*]Start date is before Christmas and End date is after Christmas break - will add the total break period to the Finish date

 

Please help with the if statement logic!

 

Thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.