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
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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.