Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
What is the easiest way to convert "1.30;00" to seconds?
The values after ";" that I guess is seconds is allways '00' so maybe it doesn't need to be taken care of.
Thanks in advance!
try this
interval(Interval#('02:30','mm:ss'),'ss')
=num( Time#('1.30;00', 'h.mm;ss')) * 24 * 3600
If I would like to use a field (that have the time format h.mm;ss) instead:
=num( Time#(field, 'h.mm;ss')) * 24 * 3600
And do it in the script?
try something like this:
Hej:
LOAD * INLINE [
Date,TimeStamp
'2014-01-02 01:30:23', '1.30;00'
];
tid:
Load
num( Time#(TimeStamp, 'h.mm;ss'))* 24 * 3600 as TimeField
Resident Hej;
You can do anything in script as long as you know that:
-DateTime field is in fact a FLOAT number where:
- the integer part = floor(DateTime) = Date info (number of days passed since 31 Dec 1899),
- the fractional part = frac(DateTime)) = Time info (time passed since midnight)
So, in our case, Time#('1.30;00', 'h.mm;ss') is converting from TEXT to TIME, using a custom format. Because you had only time info in your example I directly applied the num() function which transformed from TIME to FLOAT.
At the end I multiplied with 24 (hours) * 60 minutes * 60 seconds to transform from FLOAT to SECONDS.
Table:
Id,
Amount,
OBE,
OBK,
OBS,
num(Time#(OBE, 'h.mm;ss'))*24*3600 as OBE_Time,
num(Time#(OBK, 'h.mm;ss'))*24*3600 as OBK_Time,
num(Time#(OBS, 'h.mm;ss'))*24*3600 as OBS_Time
FROM ...;
Give me for example;
59,99999893892
120,0000003916
360,0000117347
That i guess is the right number of seconds.
Thanks!
use something like this
evaluate ( subfield(Yourfield,'.',1) *60*60 + subfield(Yourfield,';',2) * 60 + subfield(Yourfield,';',3) )
anant