Re: CSV date issue - Solved

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

 



Seems my problem was a data issue and I needed to compensate for missing
dates.

thanks,
Dan

On Thu, January 11, 2007 2:31 pm, Danny Brow wrote:
> Hi,
>
>
> It's been a while since I've used php and I'm trying to organize some
> data by date. The problem I'm having is that when the data changes from
> say 2006 to 2005 the first few rows of 2005 data goes into my 2006 data
> and the date for 2006 is lost. My code for separating dates is below with
> some sample data. I'm sure I'm missing something simple here. The date
> within the 3rd column can be ignored.
>
> TIA
>
>
>
> $num = count($data);
> for ($c=0; $c < $num; $c++) { if ($c == 5) { $data[5] =
> strftime("%m/%d/%G",strtotime('-1 Day', strtotime($data[5]))); //Fix date,
> data is off by 1 day. }
> $date = strftime("%G",strtotime($data[5]));
> if ($date == "") { //Skip row if date field is empty. // Skip
> } else {
> if ($date == 2006) { $data2006 .= "\"" . $data[$c] ."\",";
> }  elseif ($date == 2005) {
> $data2005 .= "\"" . $data[$c] ."\",";
> }  elseif ($date == 2004) {
> $data2004 .= "\"" . $data[$c] ."\",";
> }  elseif ($date == 2003) {
> $data2003 .= "\"" . $data[$c] ."\",";
> }  elseif ($date == 2002) {
> $data2002 .= "\"" . $data[$c] ."\",";
> }  elseif ($date == 2001) {
> $data2001 .= "\"" . $data[$c] ."\",";
> }  elseif ($date < 2000) {
> $data1999pre .= "\"" . $data[$c] ."\",";
> }
> }
> }
>
>
>
> Sample data
> "60609C49.PCX","PG 1","BLUEWATER HEALTH, LAB, 04/06/06","10003533S","BUNNY
>  BUGS","06/10/2006"
> "60609C50.PCX","PG 1","Cake walk, other, 04/06/06","10003533T","Tweedy
> Bird","06/11/2006"
> "50609C49.PCX","PG 1","HEALTH, LAB, 04/06/06","10003533g","Smurf
> Grumpy","06/10/2005"
> "50699C55.PCX","PG 1","Lab 101, 04/06/06","10003533p","Smurf
> Pappy","04/10/2005"
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
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