I couldn't find anywhere to ask this question and i'm working with PHP so i thought i would ask it here.
What would be the SQL statement to modify a database field from 'YYYY-MM-MM' to 'DD-MM-YYYY'.
Thanks,
I couldn't find anywhere to ask this question and i'm working with PHP so i thought i would ask it here.
What would be the SQL statement to modify a database field from 'YYYY-MM-MM' to 'DD-MM-YYYY'.
Thanks,
You can use PHP function to convert 'YYYY-MM-DD' to 'DD-MM-YYYY' :
function convertDate($date) {
$new = explode("-",$date);
$a=array ($new[2], $new[1], $new[0]);
return $n_date=implode("-", $a);
}
- Mitko Kostov
If you are using MySQL, in a query you can use the DATE_FORMAT() function http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format
to change the display format of a date. I don't believe you can change the format that the date is stored in though.
If it's a different database you'll have to check the docs. Most DBs have some function that does the same.
Thanks guys, both of those methods should be able to acieve what i need.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.