Link to home
Start Free TrialLog in
Avatar of n00b0101
n00b0101

asked on

Can you set a datetime field to default to now?

Well, really, the title says it all :)  

I tried:  ... mydate DATETIME DEFAULT NOW()

Which, threw up an error, as I assumed it would... Is there a way though?
Avatar of MMDeveloper
MMDeveloper
Flag of United States of America image

are you creating a table or inserting/updating a record?
Avatar of n00b0101
n00b0101

ASKER

creating a table
Avatar of Ryan Chong
try use timestamp data type instead?

..

`mydate` timestamp default Now()

..
try datetime DEFAULT CURRENT_DATE

mysql documentation states it needs to be a constant
No, neither suggestion worked.  :-/  Guess you can't?
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial