Reading time from an excel sheet.

R

rajendra

Hello All,

There is an excel sheet which has list of events given in time. I'm trying
to read this time using win32 module
When I do so, I get the time in General format (0.36525874).
But I want to read in hh-mm-ss. How can I achieve this?.

With Rgds,
Raj
 
C

Chad Hanna

rajendra said:
Hello All,

There is an excel sheet which has list of events given in time. I'm trying
to read this time using win32 module
When I do so, I get the time in General format (0.36525874).
But I want to read in hh-mm-ss. How can I achieve this?.

With Rgds,
Raj

Do have a look at the Win32::OLE::Variant docs but my date purposes I
use something like this:

if (ref($field)) {
if ($field->isa("Win32::OLE::Variant")) {
if ($field->Type == VT_DATE) {
$field = $field->Date("d MMM yyyy");
}
else {
warn $field->Type, " Variant type at $row_no $sheet_name\n";
}
}
else {
warn ref($field), " reference at $row_no in $sheet_name\n";
}
}

This allows me to cope with dates before and after 1900.
 
D

Darren Dunham

rajendra said:
Hello All,
There is an excel sheet which has list of events given in time. I'm trying
to read this time using win32 module
When I do so, I get the time in General format (0.36525874).
But I want to read in hh-mm-ss. How can I achieve this?.

You could do the math yourself. Excel store time/date events in days
since Jan 0, 1900. So if you're just dealing with times (not dates),
just multiply by 86400 (seconds in a day) to get it in seconds since
midnight.

$ perl -le 'print .36525872 * 24 * 60 * 60'
31558.353408

Then you can use gmtime to convert to a time.

$ perl -MPOSIX -le 'print strftime ("%H:%M:%S", gmtime(.36525872*24*60*60))'
08:45:58

I'll bet some of the time modules will work in "excel time", but I
haven't investigated to know which ones.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top