Hi all,
In a database I've got the records with the normal date format, yyyy-mm-dd.
I need to make a query which selects certain records depending on the month though, so does anyone know how I can do this?
Cheers,
Mike
Hi all,
In a database I've got the records with the normal date format, yyyy-mm-dd.
I need to make a query which selects certain records depending on the month though, so does anyone know how I can do this?
Cheers,
Mike
Don't you just love free internet games ?
Would something like this work? -
SELECT * FROM table WHERE date like '%-12-%'
(12 being the month number.)
Kate's hit the nail on the head. Thats how I'd do it
I'll give it a try, cheers folks
Don't you just love free internet games ?
Oh and while I'm at it...
Does anyone know how I could make a group by query to fetch all the different months entered into the database? I'm not sure if it's similar to the method above or not...
Thanks.
Don't you just love free internet games ?
Kate's solution will work great for selecting all dates from a certain month.
If you're trying to do a GROUP BY month, you should probably use the MONTH() function. When given a date, it returns the numerical month of the date (1 - 12).
For example:
MONTH(2004-11-23)
would return 11.
Using the month function, you could do something like this:
SELECT * FROM YourTable GROUP BY MONTH(yourDateField);
Ah right, I didn't know there was a function like that. Thanks John...
Don't you just love free internet games ?
Bookmarks