Jump to content


Photo

Dreamweaver SELECT function with date variables


  • Please log in to reply
3 replies to this topic

#1 NetNeo

NetNeo
  • Members
  • Pip
  • Newbie
  • 2 posts

Posted 13 January 2005 - 03:03 PM

I have a PHP/MySQL site that I am designing in Dreamweaver. This probelm sort of covers php and MySql and Dreamweaver.
I have been putting information into a MySQL database with the standard INSERT script built into dreamweaver. Hoever, one field is auto generated with the TIME() function and is a hidden text feild. This is being inserted find, but when I try to build a MySQL SELECT statement in Dreamweaver (or by hand even!) I cannot work out how to call all records that have been entered in a certain date. (I understand the time() includes not only date but also time information. efforts so far have resulted in no data being listed in a dynamic table and the time has obviously changed between entering the info and the SLECT function running...therefore I just get a blank list)....can Anyone help as I am realy pulling my hair out and my manager wants me to prodcue a page that will display all quotes from the database that have been done on a certain day.

Many thanks for those php/MySQL/Dreamweaver experts out there who can help

#2 pecos

pecos
  • Members
  • PipPip
  • Member
  • 15 posts
  • Locationamsterdam, nl

Posted 13 January 2005 - 04:25 PM

The TIME data-type doesn't include date-information. Use DATETIME, if you want both. Here are MySQL's date and time related function. To insert the current date, time or datetime use NOW(). And you would select today's quotes like so:

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] * FROM quotes WHERE DATE(quoteAdded) = CURDATE(); [!--sql2--][/div][!--sql3--]

(Note: Works with MySQL 4.1+)
"Shunning object orientation is like refusing to use a car on grounds that you can build your own wheel." Harry Fuecks

#3 NetNeo

NetNeo
  • Members
  • Pip
  • Newbie
  • 2 posts

Posted 13 January 2005 - 04:36 PM

Many, many (and did I say many?) thanks for this little insite to where I am going wrong. Fortunately there isnt many quotes yet so I can change the time() to datetime().

#4 pecos

pecos
  • Members
  • PipPip
  • Member
  • 15 posts
  • Locationamsterdam, nl

Posted 13 January 2005 - 04:38 PM

You're welcome!
"Shunning object orientation is like refusing to use a car on grounds that you can build your own wheel." Harry Fuecks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users