Date Difference in Hours And Minutes

ricky76ricky76 Member Posts: 204
I have two dates on a report that i want to calculate the difference in hours and minutes between them. How can i do this? My two dates for example are 10/10/05 06:03 and 10/10/05 14:33. I am able to display it as 8.5 hours or 0.35 days as the date difference but ideally i would like to display it as 8hrs 30 minutes. Any help will be appreciated.

Comments

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    If you have 2 date time fields you can subtract them into a duration

    Try to define a variable of the type Duration and see if this works for you.
  • ricky76ricky76 Member Posts: 204
    Thank you
  • ricky76ricky76 Member Posts: 204
    Is there anyway i can sum a duration field? My report is grouped and i would like to put a total in hours and minutes for each group
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    You can just do
    Duration1 := Duration2 + duration3
    
  • ricky76ricky76 Member Posts: 204
    This has not worked. I only have one variable, Duration 1, which is in the body of the report. Each grouping can have varying number of entries in it so in effect i need to sum Duration 1 which i know i can not do but am unsure how to get around it.
  • DenSterDenSter Member Posts: 8,307
    In OnPreReport (I think, it may have to go to OnPreDataItem):
    CurrReport.CREATETOTALS("Duration 1");
    
    Then you put a textbox in the groupfooter and set the SourceExpr to "Duration 1" and it should automatically display the group totals.

    What also may work is to put it into the GroupTotalFields property of the dataitem, but I hink that only works for fields.

    Just play around with those properties and commands, and read the adg about reports.
  • ricky76ricky76 Member Posts: 204
    Unfortunately this doesn't work because i can't create a total on a field that is not a decimal. Is what i am trying possible?
  • DenSterDenSter Member Posts: 8,307
    Did you try evaluation the duration into a decimal, keeping the decimal as a total and then converting it back to a duration in a groupfooter section? I am just brainstorming here, I have no idea if this will work.
  • ricky76ricky76 Member Posts: 204
    Still no joy i'm afraid but thanks for your help
Sign In or Register to comment.