Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2013
    Posts
    31

    Unanswered: SQL dates difference on Two fields Help Request

    I have the following Excel formulae/Function which calculates the dates difference

    =DAY (E2)-DAY (F2)
    E2: Represent column with Date_1 on Microsoft Access
    F2: Represent Column with Date_2 on Microsoft Access

    This formula calculates the dates ok but I need to transfer it to Microsoft Access Query designer(SQL). Basically E2&F2 are two fields on Access and I need to calculate the dates difference and if possible to show the day difference as pary of the query :
    I have done below formula which calculates dates difference but is not giving the right answers
    Expr1: Max(DateDiff("d",Now(),[date1]))
    Any help will be highly appreciated.
    Last edited by john100; 04-29-13 at 12:19.

  2. #2
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    I have done below formula which calculates dates difference but is not giving the right answers
    Please provide samples of your data, what you expect the formula to return and what it actually returned. This will help work out where the problem lies.
    10% of magic is knowing something that no-one else does. The rest is misdirection.

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    use the date time functions
    Code:
    SELECT Datediff("d",MyFirstDateColumn,MySecondDateColumn) AS NoDays from MyTable
    you'd need to replace the names of the columns (MyFirstDateColumn,MySecondDateColumn) and tablename (MyTable) with the actual names you use
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Mar 2013
    Posts
    31
    Thanks so much , I will try this tomorrow. Once again much appreciated for quick reply.

  5. #5
    Join Date
    Mar 2013
    Posts
    31
    Hi Weejas
    Thanks so much for your reply , just got a another answer and I think will work , if I have more problems I will load example to view. Once again thanks so much for your response much appreciated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •