PDA

View Full Version : [Help] SQL Databases



ThisNameWillDo!
12-12-2009, 05:30 PM
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.

Yonder
12-12-2009, 10:22 PM
Where are you adding this from directly in SQL or from a script of some sort?

ThisNameWillDo!
13-12-2009, 01:47 PM
I'm adding it directly from mySQL.

RastaLulz
14-12-2009, 05:18 AM
If you're doing it via PHP, it'd be:

<?php
$date = date("d-m-Y");
?>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..

ThisNameWillDo!
14-12-2009, 08:16 AM
If you're doing it via PHP, it'd be:

<?php
$date = date("d-m-Y");
?>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..

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.

Blinger$
14-12-2009, 08:45 AM
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.

Chippiewill
15-12-2009, 07:05 AM
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.

ThisNameWillDo!
15-12-2009, 08:08 AM
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
15-12-2009, 05:08 PM
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.

Tomm
15-12-2009, 05:14 PM
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.

Yonder
16-12-2009, 01:05 AM
Just use a plain text field in sql rather than a date one?

ThisNameWillDo!
16-12-2009, 04:04 PM
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.

That would be fantastic, I'll have to research that, if anyone finds a way to output it to DD-MM-YYYY can you tell me please? Thanks!


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.

Thank you very much.


Just use a plain text field in sql rather than a date one?

I want to make sure it's a date field because I'm going to do ages checks etc. later on.

Want to hide these adverts? Register an account for free!