my date format is like
2010-11-15 04:28:31
i want to pick just 2010-11-15 instead of 2010-11-15 04:28:31 ,
using MYSQL query ,
SELECT SUBSTR(my_date,0,6) FROM TB开发者_JAVA技巧L ,
This query retrieving just empty value ,
How to form substr function in mysql QUERY ,
MySQL uses 1-based strings, so the first character is 1, while in php the first character is 0.
Better is to use the DATE function to get the date-part only from a date time field. That is, if your field is indeed a date time field, not a (var)char field.
If you want to display your date in a specific format you can also use
DATE_FORMAT(my_date, '%Y-%m-%d')
精彩评论