#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    676
    Rep Power
    7

    Paid holidays from date range?


    Howdy. I am working on a Time Off Request form atm, and after submitted, the company wishes to display on the list the start date, end date, and number of paid holidays within this date range. I figure the paid holidays can end up in an array, but I've no clue how to do a comparison and count of such kind.

    Next step, or first if it makes it easier for submission, is the count to also be on the request form itself, so that one would be in Javascript.

    Any help would be greatly appreciated.
  2. #2
  3. hiding my <b> from ur <strong>
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2004
    Posts
    959
    Rep Power
    181
    You're not getting any responses because it's really difficult to understand what you're asking for. Please rewrite more clearly, perhaps with code examples, and indicate what you've tried.
    ****
    Enjoy my post? Drop some props by hitting the scales button up top. JBL

    Website Design in Los Angeles and Washington, DC by PoweredPages.com
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    676
    Rep Power
    7
    Well, I haven't tried much yet, just a quick attempt at Javascript, which I never touch. The goal is simple:

    Start date and End date are submitted. (Action)
    PHP calculates how many days from start to end. (Just action)
    PHP calculates how many days within this range are considered Holidays. (Action and echo'ed)
    PHP subtracts Holiday count, if any, from range count. (Action and echo'ed)

    This is some code I've tried in the Javascript manner, to be live on the form page BEFORE submitted.
    Date range calculation
  6. #4
  7. hiding my <b> from ur <strong>
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2004
    Posts
    959
    Rep Power
    181
    OK, what have you tried so far? You'd:
    1.) submit
    2.) find the number of days in the range ( http://stackoverflow.com/questions/2040560/how-to-find-number-of-days-between-two-dates-using-php )
    3.) find the number of holidays in that range. it's a bit hackish, but I'd just iterate though the days (strtotime answer on http://stackoverflow.com/questions/5...dates-with-php is probably good), then compare each one and see if it's in your range.
    4.) subtract 2 from 3
    ****
    Enjoy my post? Drop some props by hitting the scales button up top. JBL

    Website Design in Los Angeles and Washington, DC by PoweredPages.com
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    676
    Rep Power
    7
    The holiday part seems to be a bit tricky, but I think I actually got the idea n know what direction I'm aiming. Thanks for your help!

IMN logo majestic logo threadwatch logo seochat tools logo