Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
hawleyjr
- BeerMod
- Posts: 2170
- Joined: Tue Jan 13, 2004 4:58 pm
- Location: Jax FL & Spokane WA USA
Post
by hawleyjr »
I have a table that has a field that stores datetime. I would like to run a query that would return distinct dates (days).
For instance, if the field was a date field I would use the following query:
"Select distinct(mydate) from my_table"
-
hawleyjr
- BeerMod
- Posts: 2170
- Joined: Tue Jan 13, 2004 4:58 pm
- Location: Jax FL & Spokane WA USA
Post
by hawleyjr »
Nevermind I figured it out:
"SELECT DISTINCT DATE_FORMAT(dttm, '%Y-%m-%d') from my_table"
Is this the best way to do it?
-
phpScott
- DevNet Resident
- Posts: 1206
- Joined: Wed Oct 09, 2002 6:51 pm
- Location: Keele, U.K.
Post
by phpScott »
If it works then yes, is it the best, looks good to me. That is how I would probably end up doing.