|
|
How to select dates from a date fieldLet's say you have a field in MySQL that stores data in the date format ('YYYY-MM-DD hh:mm:ss) and you want to select the distinct elements of this date like day, minute or second To do this you can use MySQL's built in date functions in the query: SELECT YEAR(fieldname) as year, MONTH(fieldname) as month, DAY(fieldname) as day, HOUR(fieldname) as hour, MINUTE(fieldname) as minute, SECOND(fieldname) as second FROM mytable for more information check out the MySQL documentation page about this: MySQL Date and Time functions MySQL categoriesMySQL installation? MySQL configuration? MySQL Howtos MySQL troubleshooting? Back to > Programming |
Google SearchLogin |