Results 1 to 13 of 13
  1. #1
    Azeez_Andaman is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Location
    Port Blair, India
    Posts
    40

    Unhappy Lapse days

    Hi everybody

    in my form i have three text boxes for year, month and days and i have two date field for start date and end date. from the entries of these two date field the difference has to be supplied to the text fields. normally subtracting the start date from the end date will give the result. but what i am facing is that when the difference is in days my idea does not work and the subtraction gives me some thing like the year 1999 and so. if i use DateDiff function then i get the days but converting the days into days, month and year again gives me a wrong difference in dates because of the actual months days. if any body have any idea to resolve this problem then please help me.



    thank you

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    For
    StartDate = 04/01/2010 [Aug. 01, 2010] &
    EndDate = 08/24/2011

    What do you want your text boxes to display?
    Year =
    Month =
    Days =

  3. #3
    Azeez_Andaman is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Location
    Port Blair, India
    Posts
    40
    StartDate=01/08/2011
    EndDate=24/08/2011

    Year=00
    Month=00
    Days=24

  4. #4
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I meant what do you want displayed if:
    StartDate=14/06/2010
    EndDate=24/08/2011

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    See attached file, look at FORM1.

    It's a combination of datediff and dateadd functions.

  6. #6
    Azeez_Andaman is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Location
    Port Blair, India
    Posts
    40
    Thanks RP - u r genius
    your example is 100% useful. but when i tried i found little difference. the details are follows:- StartDate=1-2-56 : EndDate=29-2-56 : Result Shown as 00-00-28
    since both the dates are inclusive, the result should be 00-01-00
    To achieve the correct result i have tried by giving effect of 1 day in both start and end dates, but i could not get the desired result. Please once again help me.

    thanks you in advance

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Just add 1 to your day difference then, just take the existing formula for the day difference and tack on a +1

  8. #8
    Azeez_Andaman is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Location
    Port Blair, India
    Posts
    40
    Dear Rpeare

    if you don't mind please resend the code and please also check these dates

    SD=15/2/56, ED=1/3/56

    thank you

  9. #9
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    The difference for your two dates is not a month, it's 28 days. A month difference from 1/2/56 would be 1/3/56. The month difference goes from the day of the month of the one month to the same day of the month for another month.

  10. #10
    Azeez_Andaman is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Location
    Port Blair, India
    Posts
    40
    Dear rpeare

    Before beginning i would like to thank you for the ideas given me earlier. Now the programme what i am trying to develop contain a form which calculate the absent period of a worker who is an habitual absentee. they/he remain absent frequently. to find out the actual period of present in a particular period of his service it is necessary to see the broken period of service. the sample provided earlier do not clearly indicate the period of breaks; though it work fair when the break spread over months. but when it is starts from the middle of a month to the middle of next month it gives wrong result. i tried to calculate the period of absent but it does not work. Hence, i request to please spare your valuable time to make an another attempt to solve my problem.

    thanks

  11. #11
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You're asking an entirely different question than your first post.

    In the first post you wanted to be able to calculate the difference between two dates in months, weeks and days.

    Now you are asking a different question which I'm not sure I understand. Are you trying to find out how many absent days a person has between two dates vs how many days the person is present.

    For instance let's say someone was absent from 1/1/2011 through 1/14/2011 and you are looking at absentees for the entire month of january. You would want to show this person as being absent 14 days and present 17 days?

  12. #12
    Azeez_Andaman is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Location
    Port Blair, India
    Posts
    40
    Dear rpeare

    first of all sorry for the incomplete question. actually i thought if difference of two dates are separated in year, month and days then my problem is solved. but it is turned. however, i want to find out the absent period of a person in year, month and days factor in each break in his service.

    for instance let x was absent from 10-1-10 to 15-1-10 (0-0-6), again from 25-1-10 to 5-2-10 (0-0-12), 31-3-10 to 15-5-10 (0-1-16) and so for a period from 10-1-10 to 15-5-10 he was absent for (0-2-4)

    thank you very much for giving your valuable time

  13. #13
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Ok, you can't really get the results you want the way you're asking for them.

    You are artificially creating a month for x many days. What I would say you want is just a total number of days a person was absent for a given year rather than trying to display it as months/weeks years. You *can* do a number of weeks/days though because the number of days in a week is constant. If you force a month calculation it will not be accurate in the type of setup you're describing

    Let's take your example
    Person A is absent on:
    1/1/2011 - 1/14/2011 (0-2-0)
    2/2/2011 - 2/20/2011 (0-2-4)

    This person is now absent for a total of 0-4-4. Unless you artificially create a month as being 4 weeks (which only happens in february) you're going to make it seem as though the person is absent more time than they actually are.

    If just a number of weeks and number of days are acceptable that's pretty easy to come up with.

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

Similar Threads

  1. start date with lapse days
    By adar in forum Access
    Replies: 3
    Last Post: 08-07-2011, 11:08 AM
  2. Select Dates between days and two days ago?
    By rstonehouse in forum Queries
    Replies: 4
    Last Post: 08-18-2010, 02:13 AM
  3. Help with SQL: Birthdays in Next 30 days
    By kaylachris in forum Queries
    Replies: 1
    Last Post: 06-21-2010, 05:24 PM
  4. Travel days.
    By emccalment in forum Access
    Replies: 1
    Last Post: 01-06-2010, 05:39 PM
  5. less than 180 days old
    By techexpressinc in forum Queries
    Replies: 2
    Last Post: 06-04-2009, 04:29 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