Jump to content

Select Query Between Two Dates


stublackett

Recommended Posts

Hi,

 

I'm just doing a bit of archiving news by Season for a Football Site.

 

Looking to archive the news per season and it falls between these dates : 01/01/09 and 30/06/09 The date is formatted in UK Date format.

 

I've got this at the moment :

SELECT *, DATE_FORMAT( date, '%d/%m/%y' )AS uk_date FROM news WHERE newstype = 'Match Report' AND date => '01-01-09 AND <= 31-06-09' ORDER BY nid DESC

 

But its just erroring out... Any help appreciated

Link to comment
Share on other sites

Hi

 

You are checking for a date that is >= '01-01-09 AND <= 31-06-09', and that string isn't a valid date.

 

However you probably should use BETWEEN, and also use the real format for dates.

 

SELECT *, DATE_FORMAT( date, '%d/%m/%y' )AS uk_date

FROM news

WHERE newstype = 'Match Report'

AND date BETWEEN '2009-01-01' AND '2009-06-31'

ORDER BY nid DESC

 

All the best

 

Keith

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.