Comparing Stop/Start Dates and Times with LLTK
Last updated
Last updated
Lab scientists need to record both a start and stop date/time for an incubation. As a second evaluation of how many hours the incubation lasted, the scientists want BaseSpace Clarity LIMS to calculate the elapsed time.
The Lab Logic Toolkit evaluateDynamicExpression script can compare date/time entries and calculate elapsed hours. As Date fields in the LIMS do not display the required time component for this calculation, Text fields are needed.
The bash command uses a 'Date' function to convert the Text date/time entries into dates, and also uses a 'getTime' method to convert those dates into milliseconds since 1 January 1970 00:00:00 UTC. The difference between the two converted entries is then changed from milliseconds to hours.
Create a step level Text field for the Start Date/Time.
In this example, the field is named Incubation Start yyyy-mm-dd hh24:mi. The format is included in the name to assist the scientist entering the date/time.
Create a step level Text field for the Stop Date/Time.
In this example, the field is named Incubation Stop yyyy-mm-dd hh24:mi.
Create a step level Numeric field for the Incubation Hours. Set your preferred decimal place limit.
Create an automation and enter the following command line (if you have used different field names, edit the example command line to match):
Set the automation to be triggered by a button on the step. This allows the scientist to enter/edit the Start and Stop Date/Time before the elapsed hours are calculated.
Adjustment for the Start/Stop events taking place over the 'daylight savings change events' is not included in this example.
If you want to use a button to populate a Text field with the current date/time, then use: