Jump to content


Photo

get dates before from last week


  • Please log in to reply
1 reply to this topic

#1 vietboy505

vietboy505
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 10 April 2006 - 04:54 PM

<?php
//today date is: 2006-04-10 08:18:24
//last week is: 2006-04-03 06:23:10
$lastWeek=date('Y-m-d H:i:s', strtotime('-1 week'));
//How do I get any date before last week(2006-04-03 06:23:10)

//This show all date start from last week (2006-04-03 06:23:10) up to today (2006-04-10 08:18:24)
$result = mysql_query("SELECT * FROM $table WHERE dateCreate >= '$lastWeek' 
//I want the opposite of this, from before last week, not from last week up to today.
?>

How can fixed the above code to get all dates in the database from before last week? Any idea?

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 10 April 2006 - 06:53 PM

$result = mysql_query("SELECT * FROM $table WHERE dateCreate < '$lastWeek' ");

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users