Hey, when I add a field in a table on an SQL database, it automatically makes it yyyy-mm-dd, how can I make it dd-mm-yyyy?
Thanks,
Vince.

Hey, when I add a field in a table on an SQL database, it automatically makes it yyyy-mm-dd, how can I make it dd-mm-yyyy?
Thanks,
Vince.
Where are you adding this from directly in SQL or from a script of some sort?
If you're doing it via PHP, it'd be:
But if you're doing it via phpMyAdmin, I don't know, and I don't know why you'd be doing it that way..PHP Code:<?php
$date = date("d-m-Y");
?>
My last reputation was from ThisNameWillDo!.
Thanks but is there any way to insert the values for the date aswell, I don't want it to insert the current date, I want it to insert values someone has entered in the form (their date of birth).
Thanks,
Vince.
Would you just do three checks? To see if the first field is between 01-31, the second to check if the month is 01-12 and the year to be four digits.
I don't think you can? Most of the time in php you can specify the order of the date queried from the MYSQL server.
Chippiewill.
Well I've got a register form and in that form they have to enter their date of birth. One field is day of birth ($dayofbirth), one is month of birth ($monthofbirth) and one is year of birth ($yearofbirth). Then $dateofbirth = $yearofbirth - $monthofbirth - $dayofbirth. That works for me, and when I try and make it $dayofbirth - $monthofbirth - $yearofbirth it won't let me because it wants it YYYY-MM-DD, I'm just wondering if there's any way to change that?
Thanks,
Vince.
I don't think there's a way to change how it's stored, you can change the order that it is outputted though, there are some dedicated PHP codes for that me thinks.Well I've got a register form and in that form they have to enter their date of birth. One field is day of birth ($dayofbirth), one is month of birth ($monthofbirth) and one is year of birth ($yearofbirth). Then $dateofbirth = $yearofbirth - $monthofbirth - $dayofbirth. That works for me, and when I try and make it $dayofbirth - $monthofbirth - $yearofbirth it won't let me because it wants it YYYY-MM-DD, I'm just wondering if there's any way to change that?
Thanks,
Vince.
Chippiewill.
You can't change how MySQL internally stores the data but it is not limited to accepting values in that format.
See here: http://dev.mysql.com/doc/refman/5.1/en/datetime.html for acceptable formats for DATE columns.
Want to hide these adverts? Register an account for free!