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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert serial [date] to text [date]

Status
Not open for further replies.

howdthattaste

Programmer
Apr 12, 2007
17
US
how do I pass perl 39016 and convert it to 10/26/2006 ? (similar to excel's DATEVALUE function.) Is there a function or variation on localtime() to do this?

i have this feelign i need to add some padding zero's to begging or end...

thanks in advance

----------------------------------
"Not New York..., Kansas
 
actually, excel is getting it wrong.

39016 should convert to 10/28/2006 (if starting from 01/01/1900)

----------------------------------
"Not New York..., Kansas
 
Code:
use Date::Calc qw(Add_Delta_Days);
my ($year,$month,$day) = Add_Delta_Days(1899,12,30, 39016 );
my $datestring = sprintf("%02d/%02d/%4d",$day,$month,$year);
print $datestring;
 
Hey prex1,

might make a good FAQ. Do you have a real name?

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
that would make a great FAQ, and also include how to switch back. (ie. from 10/28/2006 to 54321)

Also to note incase someone does an faq, ms sql has a DATEADD() function which seems to calculate differently than excel. we might want to include different distinctions of epoch and how to adjust those variables.

----------------------------------
"Not New York..., Kansas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top