views:

41

answers:

2

hi foks,

i am facing issue while creating table where in that one column which is set to default value of current date........i would stress this point "that i need only date not time along with that"....i would be really thankfull to those who tries to help me....

A: 

Check out this set yuor field to a 'Date' not 'DateTime'

http://dev.mysql.com/doc/refman/5.1/en/datetime.html

The DATE type is used when you need only a date value, without a time part. MySQL retrieves and displays DATE values in 'YYYY-MM-DD' format. The supported range is '1000-01-01' to '9999-12-31'.

Pino
+2  A: 

Instead of trying to get MySQL to insert the current date for you when a row is created automatically, you can set it to NOW() in the INSERT query. Or, in the code for your software, you can set the date to the current date in the INSERT query.

MySQL does not support a default of the current date for DATE or DATETIME.

Jason
+1 The exception is that you can specify CURRENT_TIMESTAMP as the default for a TIMESTAMP column. http://dev.mysql.com/doc/refman/5.0/en/data-type-defaults.html
Andomar