Re: Excell to CSV Date Calculations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 02 February 2006 01:38 pm, Ray Hauge wrote:
> Hello all,
>
> I have a script that takes a CSV file in as data and does some updates to
> the DB accordingly.  Some of those values are dates.  When I save the
> spreadsheet in Open Office to a CSV file, the dates are saved as the
> internal date format of Open Office.  I need to figure out a way to convert
> that number into an actual date
>
> I know that this might not necessarily be a PHP question, but I was hoping
> to be able to solve this problem with PHP.  I checked, and MS Excel is one
> day off from Open Office on the internal date values, which throws a huge
> wrench in my program, since not everyone has Excel here.
>
> So, there are two possible solutions to my problem.  Find a way to make the
> date the text it is supposed to represent and save that in the CSV file, or
> use PHP to calculate the correct date.
>
> On a side note, I did figure out a function to be able to handle this in
> the spreadsheet, but the users will ask questions even if I show them time
> and time again how to do it.
>
> =CONCATENATE(MONTH(D2); "/"; DAY(D2); "/"; YEAR(D2))
>
> Just trying to find an easier solution :)
>
> Thanks!
>
> --
> Ray Hauge
> Programmer/Systems Administrator
> American Student Loan Services
> http://www.americanstudentloan.com
> 1.800.575.1099

Okay, I finally found the answer to my question after some more searching:

date("d.m.Y - H:i:s",(($value - 25569)*86400)-7200);

This is for Excel, but is off a day if you are using Open Office.  I think 
that will just have to be documented and people limited to one program, 
unless anyone can think of a way to distinguish one CSV file from another.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
http://www.americanstudentloan.com
1.800.575.1099

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux