Results 1 to 6 of 6
  1. #1
    Naja is offline Novice
    Windows 10 Access 2007
    Join Date
    Oct 2020
    Posts
    16

    Date Calculation

    Hi,

    I'm having an issue with a query field. I have a startDate & EndDate. I'm able to find out the number of years on a multiple contract, but I'm not able to find the yearly cost:

    10/14/2020 - 10/14/2023 = 3


    The cost for the 3 years is $60,000
    I can't seems to find the correct formula for the yearly cost
    my field for the 3 years is named Contract Duration/contract cost = $10,000, but the formula is not working. I setup the Contract duration field format as general number. What Am I doing wrong? Thanks in advance.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Post sample data and attempted query SQL statement. If you want to provide db for analysis, follow instructions at bottom of my post.
    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
    Naja is offline Novice
    Windows 10 Access 2007
    Join Date
    Oct 2020
    Posts
    16
    Quote Originally Posted by June7 View Post
    Post sample data and attempted query SQL statement. If you want to provide db for analysis, follow instructions at bottom of my post.
    here you go:

    Click image for larger version. 

Name:	Date Calculation.JPG 
Views:	23 
Size:	80.2 KB 
ID:	43225

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Well, from what I can see, that should work. You did not provide query SQL statement.
    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.

  5. #5
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    From your image in Post #3, it looks like the contract duration is a text field (the number 3 is left justified).

    This is the query I used:
    Code:
    SELECT StartDate, EndDate, ContractCost, DateDiff("yyyy",[startdate],[enddate]) AS ContractDuration, [Contractcost]/[contractduration] AS YearlyCost
    FROM Table1;
    Note:
    I removed the spaces in field names.
    Use your table name....
    Attached Files Attached Files

  6. #6
    Naja is offline Novice
    Windows 10 Access 2007
    Join Date
    Oct 2020
    Posts
    16
    It worked, thank you so much for your help. Much appreciated.




    Quote Originally Posted by ssanfu View Post
    From your image in Post #3, it looks like the contract duration is a text field (the number 3 is left justified).

    This is the query I used:
    Code:
    SELECT StartDate, EndDate, ContractCost, DateDiff("yyyy",[startdate],[enddate]) AS ContractDuration, [Contractcost]/[contractduration] AS YearlyCost
    FROM Table1;
    Note:
    I removed the spaces in field names.
    Use your table name....

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

Similar Threads

  1. Date Calculation
    By PTR in forum Access
    Replies: 15
    Last Post: 05-08-2017, 09:58 AM
  2. Replies: 1
    Last Post: 02-10-2017, 03:10 PM
  3. Due Date Calculation
    By DFeil in forum Access
    Replies: 3
    Last Post: 10-29-2015, 10:55 AM
  4. Date Calculation
    By dharsh in forum Access
    Replies: 3
    Last Post: 06-26-2013, 11:19 AM
  5. Date Calculation ?
    By techexpressinc in forum Queries
    Replies: 2
    Last Post: 06-24-2009, 09:02 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