Jump to content


Photo

Logic help, please?


  • Please log in to reply
4 replies to this topic

#1 Moron

Moron
  • Members
  • PipPipPip
  • Advanced Member
  • 368 posts

Posted 28 August 2006 - 06:51 PM

$combodate = "$RESULT[LYR]$RESULT[Lmo]$RESULT[Lda]";
//combine year, month, date into a string.

$combodatecode = strtotime($combodate);
//convert to UNIX timestamp.

$lastjuly1 = date($last,0701);
//"$last" is the last year in which July 1 existed. I didn't include it here.

$lastjulycode = strtotime($lastjuly1);
//convert to timestamp.

echo "<td>";
echo $RESULT['Lmo'];
echo "/";
echo $RESULT['Lda'];
echo "/";
echo $RESULT['LYR'];
echo "</td>";


Okey-dokey. All of the above functions work because I can echo them and get a date or a timestamp, respectively. Here's the kicker.... if I echo $combodate, it seems to pull the date of a random record. If I leave it out, the above Lmo, Lda, and LYR lines pull records perfectly. It almost seems like I need to restrict records that don't exist yet until after $RESULT is called.

I tried...

if ($combodatecode >= $lastjulycode)  {

echo "<td>";
echo $RESULT['Lmo']; 
echo "/";
echo $RESULT['Lda'];
echo "/";
echo $RESULT['LYR']; 
echo "</td>";

}

No go. It pulled two records when it normally (and should) pull eight.
I also tried this inside the while loop. No go.

Ideas?


#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 28 August 2006 - 07:58 PM

$combodate = mktime(null, null, null, $RESULT['Lmo'], $RESULT['Lda'], $RESULT['LYR']);

$lastjuly1 = mktime(null, null, null, 7, 1, $RESULT['LYR'] - 1);

echo '$combodate = ' . $combodate . ' which is: ' . date("Y-m-d", $combodate) . "<br />";
echo '$lastjuly1 = ' . $lastjuly1 . ' which is: ' . date("Y-m-d", $lastjuly1);


#3 Moron

Moron
  • Members
  • PipPipPip
  • Advanced Member
  • 368 posts

Posted 28 August 2006 - 08:17 PM

$combodate = mktime(null, null, null, $RESULT['Lmo'], $RESULT['Lda'], $RESULT['LYR']);

$lastjuly1 = mktime(null, null, null, 7, 1, $RESULT['LYR'] - 1);

echo '$combodate = ' . $combodate . ' which is: ' . date("Y-m-d", $combodate) . "<br />";
echo '$lastjuly1 = ' . $lastjuly1 . ' which is: ' . date("Y-m-d", $lastjuly1);


Thanks. This code works, but how do I incorporate it into the while satement? In other words, I only want to display records from the previous July 1 of the fiscal year ($last).


#4 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 28 August 2006 - 08:39 PM

what format are you storing the date in your database?

#5 Moron

Moron
  • Members
  • PipPipPip
  • Advanced Member
  • 368 posts

Posted 29 August 2006 - 12:04 PM

what format are you storing the date in your database?


It's Month (2-digit), Day (2-digit), and Year (4-digit).

Thanks!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users