If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Default date values in MySQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-03-04, 10:06
richy240 richy240 is offline
Registered User
 
Join Date: Sep 2003
Posts: 24
Red face Default date values in MySQL

How can I make a field automatically use today's date in YYYY-MM-DD format (Date datetype)? I tried a few different ways, but nothing worked. I have even searched the MySQL manual online... Please help!

Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 08-03-04, 11:38
yellowmarker yellowmarker is offline
Registered User
 
Join Date: Jul 2004
Location: Dundee, Scotland
Posts: 107
MySQL itself does not provide functionality so that a date field will default to "today's date" (in the MySQL table definition). You can for example insert today's date using a MYSQL function in the INSERT SQL. See CURDATE(), CURTIME(), NOW().
Reply With Quote
  #3 (permalink)  
Old 08-03-04, 11:49
richy240 richy240 is offline
Registered User
 
Join Date: Sep 2003
Posts: 24
OK - I will have to use a 'hidden' field in my form to handle the default value of the 'date_created' field. (I am using this DB as a backend for an Access frontend.) Thanks for your help!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On