Results 1 to 6 of 6
  1. #1
    bsvubana is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2012
    Posts
    3

    Half-day leave computation


    if half-day leave is checked in my sub-form deduction should be .5 days. How can I total all "Days applied" in my subform and show the result computation in my "Available Leaves" in my mainform

    Available Leaves = Leave Allocation - Days applied

    Note: If half-day leave is checked deduction is .5 days applied.

    I Attached my working database. Thanks
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    You show leave range of 9/10/2012 to 9/15/2012. The 10th through 15th is a 6-day period inclusive of the begin/end dates. DateDiff calculates this range as 5 days but if the leave range should be inclusive of the begin and end dates (and in my experience with payroll, that is customary) then the number of days is 6.

    Can the 'halfday' option apply to more than one day? I ask because you show some records like that in the Transaction table.

    Enter the date range as inclusive, such as 9/10/2012 to 9/14/2012 and consider:

    Days applied: (DateDiff("d",[datefrom],[dateto])+1)*IIf([halfday]=True,0.5,1)

    How do you want to handle if date range crosses weekends and holidays?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Try using

    Code:
    Days applied: IIf([halfday]=0,DateDiff("d",[datefrom],[dateto]),0.5)
    in your query.

    Thanks

    Edit : Sorry June, missed your post.

  4. #4
    bsvubana is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2012
    Posts
    3
    Guys, Thanks so much for this it solved my query problem! How could I bypass weekends and holidays on the specified date range to be counted?

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    That gets complicated.

    Google: calculate date difference excluding weekends holidays

    Review http://bytes.com/topic/access/answer...idays-weekends
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    bsvubana is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2012
    Posts
    3
    thanks much!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Rounding number up to half hour
    By crxftw in forum Forms
    Replies: 2
    Last Post: 08-23-2011, 07:29 AM
  2. Replies: 5
    Last Post: 07-29-2011, 12:55 AM
  3. Round up time half an hour
    By JBM18 in forum Queries
    Replies: 2
    Last Post: 12-09-2010, 11:56 AM
  4. run a half dozen reports from 1 click
    By techexpressinc in forum Reports
    Replies: 2
    Last Post: 12-17-2009, 11:20 AM
  5. help need on query report on who is on leave
    By islandboy in forum Forms
    Replies: 10
    Last Post: 08-17-2009, 12:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums