Duration (duration)
Description
Transforms a string or integer representing an amount of time into duration type. The input must follow a specific format to be transformed. The following table lists the accepted input formats and their corresponding outputs in duration type:
Type | Input (string) | Output (duration) | Example |
---|---|---|---|
Days | (0...n) day(s) | (0...n)d | 1 day → 1d |
Hours | (0...n) hour(s) | (0...23)h | 15 hours → 15h |
Minutes | (0...n) minute(s) / min | (0...59)m | 45 min → 45m |
Seconds | (0... n) second(s) / sec | (0...59)s | 50 seconds → 50s |
Milliseconds | (0...n) | (0...999) | 300 → 300 |
Note that milliseconds have no symbol representation, so the string or integer will be simply transformed to duration data type, with no modification.
You can combine different amounts of time in your string and convert them into a duration. For example, if you enter 2 days 10 hours 30 minutes, it will be transformed into 2d10h30m. When you enter several amounts of time in a single string like this, separate them using blank spaces as in the example. Commas and other symbols are not accepted.
How does it work in the search window?
Select Create column in the search window toolbar, then select the Duration operation. You need to specify one argument:
Argument | Data type |
---|---|
Duration (mandatory) | string, integer |
The data type of the values in the new column is duration.
Example
In the my.upload.sample.data
table, we want to transform the strings representing durations in the Duration strings column into duration data type. To do it, we will create a new column using the Duration operation.
The arguments needed to create the new column are:
Duration - Duration strings column
Click Create column and you will see the following result:
How does it work in LINQ?
Use the operator select
... as
... and add the operation syntax to create the new column. This is the syntax for the Duration operation:
duration(string)
Example
You can copy the following LINQ script and try the above example on the my.upload.sample.data
table. Keep in mind that you need to download and upload the file provided before to your Devo domain.
from my.upload.sample.data
select split(message, ";", 4) as durationStrings
select duration(durationStrings) as duration