Calculating and Using Time Differences (CDS 2.7):

 I need to enter two times based on experimental data, and use those values in a datediff function.  The calculations related to radioactive decay.  I have set up Report Parameters for the two times, formatted as datetime.  However, when I execute the report I am unable to enter a time; I can only enter the date.  Are the report parameters incorrectly configured, or is this not possible?  The entry box allows me to enter a date but I cannot continue to adding the time.

Or is there a better way to do this?

Certainly I could just change the default for the report parameters each time I generate a report, but that seems like a clumsy workaround.

  • Hello,

    It is just the way the date selection dialog is setup in the software for IR parameters. You might look at creating custom fields in your projects for the dates you need. You could then enter the date and time for those custom fields when you setup the injections or in the injection list when processing the data. 

    Marty Adams

  • Marty:
    Thanks.  This information confirms what we have been seeing.  I was trying to avoid custom fields for a number of reasons but it has to be back on the table, I guess.

    We did find another workaround, though.  If you make the Report Parameter a Multi-Value type, then you can edit the time in the drop-down list and it works as planned.  Only slightly less convenient.  Of course, then you need to change all the variables to account for the position in the multi-value list (e.g., vartime1(0), vartime2(0)).  I was able to find information about this in the Help System - and I will give them credit for providing a good explanation and example (that doesn't happen often with Help systems).

    Another comment for those who might need to use datediff to match spreadsheet calculations: in Excel, if you subtract a later time from an earlier time you get a negative number, and many formulae will have the necessary "-1" to correct for that.  Note that datediff generates a positive number only, the difference, regardless of direction.  Adjust your calculations accordingly.

  • Hello,

    I guess for the last issue you could use something like I use for determining the time between injections in a report. We can only store numeric values directly as variables in IR, so you cannot store dates. The means you cannot store the previous rows injection date to do a datediff. What you can store is the time is seconds from a date constant, I chose a time in the past before any injections could have been done. In the example below, I store the value in a hidden column after the column where I use the variable. This mean for the first row there is no value for TimeInj in my display column, so the value is blank. In the second row, the value for TimeInj is the time difference from the first row which I subtract from the current injections time difference from the past date constant. I divide by 60 to change the output to min. 

    Marty Adams

    Display Time Difference

    Hidden Column for time from previous row.

    Date in the past as an internal parameter.

    Final Report

Was this helpful?