Results 1 to 9 of 9
  1. #1
    mohiahmed is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Posts
    23

    Date problem

    Hi all,

    I am really stuck with this problem. This is a two part problem and I don't know if it can be solved in access but I know it can be done in Excel.

    1) I have the field "Application Date" and "DOB." I want to find out the amount of days between "Application Date" and "DOB+3years."
    i) is it possible to create a field that adds 3 years to the date of birth(DOB)?


    ii)Would access give me, in days, the difference between "Application Date" and "DOB+3years."

    2) If the above is possible I then want to have a calculated field which takes into account the difference mentioned above. I want the top 25% to receive a certain amount of points, lets say 25 points then the next 25% to receive 15 points and then the next 25% to receive 5 points and 0 points for the final 25%.

    Could this be done in access? If so can anyone guide me please?

    Thank you.

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    1) Use the DateDiff function - it will do all you ask.

    2) what do you mean by "top 25%"? What is the actual formula to get that number?

  3. #3
    mohiahmed is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Posts
    23
    1) Thank you, this worked perfectly!

    2) What I mean is, each individual record will now have a figure for the difference. Lets say we have 4 records only, e.g.
    Name Difference(days)
    1) John Smith 38
    2) Gordan Bennet 55
    3) Casper White 88
    4) Bart Simpson 101

    I would like to give points 25 points to the top 25% (according to the least days difference) - So John Smith should receive 25 points as he is in the top 25% being the lowest of the four. Then Gordan would receive 15 points for being the in the next 25% etc...

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Access does not do what Excel does - you have to do it all yourself. So you need to write out the formula first, then it can be translated into Access. You need to be able to write it out in such a way that you or I or anybody can take any set of records and apply them to the formula and the same answer will come out each time. Using 4 records is too easy, use 11. Once we know what the formula is we can then translate it into query code or VBA or whatever.

  5. #5
    mohiahmed is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Posts
    23
    Quote Originally Posted by aytee111 View Post
    Access does not do what Excel does - you have to do it all yourself. So you need to write out the formula first, then it can be translated into Access. You need to be able to write it out in such a way that you or I or anybody can take any set of records and apply them to the formula and the same answer will come out each time. Using 4 records is too easy, use 11. Once we know what the formula is we can then translate it into query code or VBA or whatever.
    Ok, so with 11 records on the database, the top 2(with the least difference between the date they applied and their dob+3years) will receive 25 points, then the 3rd to the 5th will receive 15points, the 6th to 8th should receive 5points and 9th to 11th 0 points.

    I hope I've made myself clear. I'm not sure if access can do this?

  6. #6
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Like I say, Access can do just about anything - it is just that YOU have to tell Access to do it. If something can be written down then it just needs to be converted into Access-speak. Access doesn't understand words like "top". A formula is written like this:
    (a + b - (c / d)) * (100 / 7.5) etc.
    That is what you need to get to before you can put it into Access, a formula that will work on any set of record.
    I'm not good with mathematics at all (I always find someone to help me!). It may be something like add up all the number of days and dividing by 4, or something like that?

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    3 Years from today (today) is Date
    dateadd("yyyy",3,date) = 21/01/2015

    Days difference between today and 3 years from today

    ?datediff("d",date,dateadd("yyyy",3,date))
    1096

    With your fields ApplicationDate and DOB

    DobPlus3 = Dateadd("yyyy",3,DOB)

    DifferenceInDays is DateDiff("d",ApplicationDate,DateAdd("yyyy",3,DOB)

    Create a query to get that info.
    Select PersonName,DateDiff("d",ApplicationDate,DateAdd("y yyy",3,DOB) as DifferenceDays FROM MyTable Order By DifferenceDays;

  8. #8
    mohiahmed is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Posts
    23
    Thank you orange, if I understand right then what you have mentioned just orders them but is there no formulae that gives points depending on number of ppl in the database?

  9. #9
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    True, now you can create another query to act on the first query or create some vba to process the first query as a recordset.

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

Similar Threads

  1. Having problem in date format
    By paddybear in forum SQL Server
    Replies: 3
    Last Post: 01-06-2012, 01:22 AM
  2. Date problem
    By farhanahmed in forum Access
    Replies: 1
    Last Post: 04-01-2011, 10:12 AM
  3. Problem With Date
    By jlg759 in forum Programming
    Replies: 6
    Last Post: 07-02-2010, 12:40 PM
  4. Problem with date when importing
    By ds_8805 in forum Import/Export Data
    Replies: 5
    Last Post: 01-27-2010, 02:30 AM
  5. Date Problem
    By oldteddybear in forum Queries
    Replies: 1
    Last Post: 08-30-2009, 08:52 AM

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