Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to translate Excel dates to perl

Data manipulation

How to translate Excel dates to perl

by  prex1  Posted    (Edited  )
Excel stores dates as serial numbers, representing the number of days past one of two optional starting dates (the default in Windows is 00 Jan 1900, as day one is 1 Jan 1900).
Perl uses the number of seconds past the 'epoch', and the epoch on most systems is 1 Jan 1970.
To translate an Excel serial number to perl time, when the reference dates are the defaults as above, use the following
Code:
print scalar gmtime(($ExcelDate-25569)*86400);
This will display something like [tt]Fri Jul 27 09:39:11 2007[/tt], but may be rearranged by using the list output of [tt]gmtime()[/tt] or [tt]localtime()[/tt])
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top