Jump to content
xisto Community
Sign in to follow this  
feipoh

Php -date Format & Initial Field Default Value

Recommended Posts

Hello ,On most tutorial website for mysql all the date format is in this form 2006-10-17..User table-----------User_name VARCHAR(20),Join_date DATE,Alive VARCHAR(1),..etc etc I was wondering , 1) is it possible that i can put the date in this format 17/10/2006.. rather the usual 2006-10-17??Also.... how can i initial a default value to a column..e.g...Alive VARCHAR(1) NOT NULL,When i create a table User2) How can i initial 'Y' Or 'True/false' as the initial value in column Alive, e.g... if i type DESCRIBE USER Field Type NULL Defaultit will show-> user_name varchar(20) No Join_date date No No 00/00/0000 Alive varchar(1) No YOR DESCRIBE USER Field Type NULL Defaultit will show-> user_name varchar(20) No Join_date date No 00/00/0000 Alive boolean No TrueThank you!

Share this post


Link to post
Share on other sites

It would have been better, if you had put this into PHP section of the forums... Mods, please move it when you see it...

Here's an example of what you are trying to do:

CREATE TABLE `probni` (`field1` VARCHAR(20) DEFAULT 'field test' NOT NULL,`field2` DATE DEFAULT '00-00-0000' NOT NULL,`field3` VARCHAR(1) DEFAULT 'Y' NOT NULL);

As you can see, you should only put DEFAULT keyword, before setting the new default value for the field... Also, I don't think you can change the format of the DATE field, if you're not comfortable with it, use your own format, in a regular text field, or UNIX timestamp in a number field... I think that about covers it...

Oh yes, there is no BOOLEAN type in MySQL (at least in version 4.x), so you can either use ENUM, and specify True and False as it's values (or Yes/No, or others), or use number type, and use 1 and 0...

Hope this helped...
Edited by Galahad (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.