Jump to content

compare dates


denoteone

Recommended Posts

I was given a csv file with a column for dates. they are in this format:

8/27/2008 12:49

 

i want to pass a variable in my url so that I can search by database so that I return everything from that date on.

 

so the url would be    www.mysite.com?date=08/01/2008

 

can i use that variable to search the date field in my database?

something like

$date = $_GET['date'];

$query = "SELECT *FROM tablename WHERE postDate >= '$date'";  
$result = mysql_query($query)or die (mysql_error());

 

 

Link to comment
Share on other sites

Depends on what data type postDate is in. Dates in MySQL are usually in format YYYY-MM-DD H:i:s. You don't need the hours, minutes, seconds, but your date should be in YYYY-MM-DD format. So I don't think MM/DD/YYYY is a valid date format.

Link to comment
Share on other sites

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.