Results 1 to 7 of 7
  1. #1
    TrulyVisceral is offline Total N00B
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2018
    Location
    Deimos
    Posts
    102

    Question Making a report with time differences.

    Cool, so, I'm making a simple report where I'm just showing the time difference between 2 times.
    It's just =DateDiff("d",[Inicio de la interrupción de servicio],[Fin de la interrupción de servicio])

    Where "Inicio" is the start and "Fin" is the end. It works alright, but as you can see in the formula, it's days.
    But if the time difference is less than a day, it just shows a 0. I want to make those into hours, since there's still time there, not just 0, I want to make all the zeroes into hours, rather than days.



    HOWEVER, I don't quite get the IIF command. I was thinking of adding:
    =IIF([Diferencia]<1,(=DifFecha("hh:mm",[Inicio de la interrupción de servicio],[Fin de la interrupción de servicio]),"error")

    CONTEXT: "Diferencia" is the field where the time difference is shown.

    BUt, well, I get errors. I'm not getting the format... halp.

    For now I just have a 2nd field where it is indeed shown in hours. Regardless.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    in the query, if days diff>0, show days, else show hours:


    IIF(DateDiff("d",[Inicio de la interrupción de servicio],[Fin de la interrupción de servicio])>0,DateDiff("d",[Inicio de la interrupción de servicio],[Fin de la interrupción de servicio]),DateDiff("h",[Inicio de la interrupción de servicio],[Fin de la interrupción de servicio]))

  3. #3
    TrulyVisceral is offline Total N00B
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2018
    Location
    Deimos
    Posts
    102
    Not quite, but thanks anyways. I thought of formatting it like "hh:nn:ss".
    Since that's how it's like in the excel sheet i got this data out of.

    nvm, not quite once more.

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Date fields are stored as double number datatypes no matter how they are displayed e.g 42165.25
    The integer part is the number of days since 30Dec 1899 and the decimal part is the fraction of a day.
    So 0.25 is 06:00 or 6.00am

    Use this fact to calculate your time diff in hours
    Convert datetime values to doubles, and calculate the difference, multiply by 24 to get hours.

    Code:
    =24*(CDbl([End])-CDbl([Start]))
    This will give results like 12.75.

    If you want this to be shown as 12:45 do a further calculation to get the minutes e.g. 60*0.75

    If you only want the whole number of hours, either use Round function with 0 d.p. Or the Fix function to get the completed hours.
    For an answer of 12.75, these will give 13 rounded or 12 using Fix
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    TrulyVisceral is offline Total N00B
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2018
    Location
    Deimos
    Posts
    102
    Alright. Got it. That should do it. Many thanks.

    Might need help with graphics in a bit though. Let me see for myself first tho.

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    You're welcome but ...graphics?
    I draw the line at drawing clocks in Access
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    TrulyVisceral is offline Total N00B
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2018
    Location
    Deimos
    Posts
    102
    I mean, I'll ask in a different thread.

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

Similar Threads

  1. Replies: 4
    Last Post: 12-20-2017, 09:45 PM
  2. Replies: 2
    Last Post: 01-25-2017, 08:36 AM
  3. Replies: 7
    Last Post: 09-15-2014, 11:55 AM
  4. Replies: 1
    Last Post: 09-07-2011, 02:42 AM
  5. Having a hard time programmatically making reports
    By blacksaibot in forum Programming
    Replies: 6
    Last Post: 01-20-2010, 03:53 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