Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
April 13–15 - Dare to Unleash a New Professional You at Qlik Connect 2026: Register Now!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

convert time

Hi
I am having time of the date in the format 0.39886574074074 which actually is represent of the 9:34:22 time .
Does anyone know how I can convert number 0.39886574074074 to be this time format using talend .
Thanks
Zeljka
Labels (2)
20 Replies
Anonymous
Not applicable
Author

I think you can use Java routine. Make your own function to convert your format.
Benoît
Anonymous
Not applicable
Author

As I am not really Java developer could you please give me some sugestion...
Thanks
Anonymous
Not applicable
Author

I can try to help you but, can you explain me first how to convert the format.
I didn't understand how you pass from 0.39886574074074 to 9:34:22.
Benoit.
Anonymous
Not applicable
Author

I am having this format in csv file which data I am mapping.
The format of time is what I stated 0.398865741 as cell was formated as general .
However, I know is easy if I just reformat cell to be Time but I am not aloud to change any date and I need to upload date in format as it is and just after in Talend can do any changed...
I have look how to do this using some talend components but wasnt' much luck that is reason why I asked for help...
thanks
Anonymous
Not applicable
Author

I still didn't understand what means your number 0.398865741 ?
My question was how you can conclude the number 0.39886574074074 is the folowing time 9:34:22 ?
?
0.39886574074074 -> 9:34:22
Thanks,
Benoît.
Anonymous
Not applicable
Author

This number was in my csv document which I have opend using excel.
When you check format cell for that number is showing you General option but when I chose Time option giving me time which I actually need but can not change in excel have to be changed in Talend when I created file delemeted and do mapping.
Please see images
Anonymous
Not applicable
Author

Sounds like your not sure what excel is doing to your data. If you can avoid sourcing data from excel, its ALWAYS a good idea to do so.
That said, if you're stuck reading excel files (I am so so sorry) -- here's the skinny
Excel stores dates as sequential numbers known as serial values. Excel stores times as decimal fractions because time is considered a portion of a day. Dates and times are values and so you can add, subtract, and include dates and times in other calculations.
For example, to determine the difference between two dates, you can subtract one date from the other. You can view a date as a serial value and a time as a decimal fraction by changing the format of the cell that contains the date or time to General format.

so its just fractional days... I can write a converter for that 0683p000009MA9p.png
This is in Perl cause I had it handy... if you're still stuck, I can convert to java for you
#!/usr/bin/perl -w
use strict;

my $excel_time = 0.398865741; #9:34:22
my $sec_in_day = 86400;
my $min_in_day = 1440;
my $hour_in_day = 24;
#int function just truncates decimals
my $h = int($excel_time * $hour_in_day); #hours are easy
my $m = int(($excel_time * $min_in_day) - $h * 60); #minuets, minus the hour portion
my $s = int(($excel_time * $sec_in_day) - (($h * 60 * 60) + $m * 60)); #seconds minus the hours and min portion

print "$excel_time --> $h:$m:$s \n";
Anonymous
Not applicable
Author

thanks for this perl but I am using java ..
do you mind to give me some java exampe. ..
Anonymous
Not applicable
Author

I do know what excel doing to my date but the problme as our client sending us files in that fomat and we are not aloud to change any orginal document just to use and do ETL data for our use and convert by talend but not touching any orginal document..
I am not java developer I am more Database person and now I am stuck with this java code, had tried to find some solution but did not have much luck..
will be great if you can help ..
Thanks