Jump to content

Recommended Posts

hi, i am using the following code to retrieve information for todays date:

<?php
			$query =  "select * from customer where DATE (date) = DATE(NOW())";
			$result = @mysql_query($query, $connection) 
			or die ("Unable to perform query.<br />$query<br/>");

			$num_rows = mysql_num_rows($result); 	
			echo "$num_rows"; 
			?>

 

i cant seem to find any code to extract information from yesterdays date. can you help please?

 

The @ is supressing any useful errors.  Try this and see what the error says, (my bet is the DATE being used a column name).

 

$result = mysql_query($query, $connection) or trigger_error("MySQL Query Failed: " . mysql_error());

 

See what the shows ya.

no the code i posted is fully working code and retrieves the information i need data entered for todays date. the question was how can i adapt this to retrieve information for yesterdays date.

 

for example show all records where date = yesterdays date.

perhaps this snippet may point you the way...

 

WHERE date = DATE_ADD(CURDATE(), INTERVAL -1 DAY)

 

EDIT!

 

that did work when i inserted my saved date value.

 

$query =  "select * from customer WHERE date (date) = DATE_ADD(CURDATE(), INTERVAL -1 DAY)";

 

thanks very much for your help  8)

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.