Mysql Query - using Date functions

Hi
I need a bit of help getting a couple of db queries working which work with a date stored in a mysql database.

Query 1
This needs to pull out all rows where invoice_date is greater or equal than the provided date, below is my current attempt

SELECT * FROM invoices WHERE invoice_status = 'sent' AND invoice_date >= 2007-06-14

Query 2
This needs to pull out all rows where invoice_date is in a certain month (based on a YEAR and MONTH 10)

SELECT * FROM invoices WHERE invoice_status = 'sent' AND MONTH('invoice_date') = 10 AND YEAR('invoice_date') = 2007

ANy suggestions would be much appriciated

Many thanks
-s-
LVL 1
socrossAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you need to apply quotes around the date value:
SELECT * FROM invoices WHERE invoice_status = 'sent' AND invoice_date >= '2007-06-14'

resp:
SELECT * FROM invoices WHERE invoice_status = 'sent' AND invoice_date >= '2007-06-01' AND invoice_date < '2007-07-01'
0
 
socrossAuthor Commented:
great thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.