Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Good day
Please can you help me format a number to a time?
Numbers
600
612
700
730
1805
The times for the above should be:
06:00
06:12
07:00
07:30
18:05
I've tried using Time#(Number,'HH:MM') and Time(Number,'HH:MM') but both do not seem to work.
Please help - Thank you
Try like:
If(Len(Numbers)=3,Time(Time#(Numbers,'hmm') ,'hh:mm'), Time(Time#(Numbers,'hhmm') ,'hh:mm') ) as NewTime
Hi,
It should be
Time(Time#(Number,'Hmm'), 'HH:mm')
Hope it helps
Try like:
If(Len(Numbers)=3,Time(Time#(Numbers,'hmm') ,'hh:mm'), Time(Time#(Numbers,'hhmm') ,'hh:mm') ) as NewTime
Hi try below
=time(time#(Numbers,'hmm'),'h:mm')
Regards
ASHFAQ
Great!!! - Thank you Thank you
Does it work for 4-digit number ?
Try this:
LOAD *,
Time#(Mid(Number,1,2) & ':' & Mid(Number,3,2),'HH:mm') as FormatedTime;
LOAD if(len(Number)=3,'0'&Number,Number) as Number;
LOAD * INLINE [
Number
600
612
700
730
1805
];
Wonderful - this takes into account the change in the length of the number too - Thank you
No I missed that. But you can implement like below, instead of going for If condition
Time(Time#(Num(Number, '0000'), 'HHmm'), 'HH:mm')
Or like this
Time(Time#(Left('0'&Number,4),'HHmm'), 'HH:mm')