Hello,
I want to make it so that in my table when a row gets inserted I want to have the date of insert, this cannot change anymore.
In phpMyAdmin I set it to
Field: date
Type: date
attributes:
Null: Yes
The value 0000-00-00 is the default value for the date in a MySQL database. When entering a date, using the command curdate(), the date will show up in the database in the year-month-day format. Hence the 0000-00-00
its only fresh in my mind because I am setting up my first db and tables at present - but that has worked no probs with me. and you don’t want users to input a date as you can get into all sorts of hassles then!
Yep, I will be using the date-function as well in a database, I first have to set up some other functions and make sure they work, and then I will certainly shut of that default, I don’t like it :D.
what are you talking about? of course you will still get 0000-00-00 if the column is NOT NULL. 0000-00-00 IS NOT NULL. if the col wasn’t NOT NULL, the value would be NULL if you didn’t specify a value.
It was more in line with using CURDATE() and the format for the db rather than not null etc…
As the case was George was getting 0000-00-00 and hence that was what we were trying to resolve DATE NOT NULL is the correct syntax for the date field so its always filled in - if you use CURDATE() tell me how you can get 0000-00-00? I’m interested to know?!
ok, i understand what you’re sayin. but, you said the format was “date DATE NOT NULL”. he didn’t need to know that, he already had the column declared right (except it was NULL) and he only wanted to know how to insert the date.
your post implied that you won’t get 0000-00-00 if the col is NOT NULL, which isn’t true.
yes, if you always use CURDATE() you won’t get 0000-00-00… BUT you won’t get NULL either. so therefore the column does not need to be NOT NULL. in some cases you may want/need it to be able to be NULL if your app needs to differentiate between no value and 0000-00-00.