Skip to main content
Inspiring
March 23, 2009
Question

CURDATE() as default for a MySQL field?

  • March 23, 2009
  • 5 replies
  • 6770 views
I can do this, right?

ALTER TABLE `tblClassDetails` ADD `detailsStart` DATE NOT NULL DEFAULT
'CURDATE()' AFTER `detailsDate` ;

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


This topic has been closed for replies.

5 replies

Inspiring
March 23, 2009
I had considered that originally and discarded it as not satisfying my
needs. Now that I think about it, though, it might. I'll give it a try and
see what happens.

Thanks you and Joe!

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"David Powers" <david@example.com> wrote in message
news:gq8ic5$f7a$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> Argh! What *can* I do to make the default value be the current date
>> (YYYY-MM-DD), then?
>
> I never thought you'd ask. ;-)
>
> Use a TIMESTAMP column.
>
> ALTER TABLE `tblClassDetails` ADD `detailsStart` TIMESTAMP DEFAULT
> CURRENT_TIMESTAMP AFTER `detailsDate`
>
> Do not include that column in any INSERT or UPDATE queries. It should then
> set the current date and time on insert, and remain unchanged on update.
>
> --
> David Powers
> Adobe Community Expert, Dreamweaver
> http://foundationphp.com

Inspiring
March 23, 2009
Murray *ACE* wrote:
> Argh! What *can* I do to make the default value be the current date
> (YYYY-MM-DD), then?

I never thought you'd ask. ;-)

Use a TIMESTAMP column.

ALTER TABLE `tblClassDetails` ADD `detailsStart` TIMESTAMP DEFAULT
CURRENT_TIMESTAMP AFTER `detailsDate`

Do not include that column in any INSERT or UPDATE queries. It should
then set the current date and time on insert, and remain unchanged on
update.

--
David Powers
Adobe Community Expert, Dreamweaver
http://foundationphp.com
Inspiring
March 23, 2009
On 23 Mar 2009 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:

> Argh! What *can* I do to make the default value be the current date
> (YYYY-MM-DD), then?

http://dev.mysql.com/doc/refman/5.0/en/timestamp.html

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/contact.php
Inspiring
March 23, 2009
Argh! What *can* I do to make the default value be the current date
(YYYY-MM-DD), then?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"David Powers" <david@example.com> wrote in message
news:gq8elk$ac1$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> I can do this, right?
>>
>> ALTER TABLE `tblClassDetails` ADD `detailsStart` DATE NOT NULL DEFAULT
>> 'CURDATE()' AFTER `detailsDate` ;
>
> No.
>
> --
> David Powers
> Adobe Community Expert, Dreamweaver
> http://foundationphp.com

Inspiring
March 23, 2009
Murray *ACE* wrote:
> I can do this, right?
>
> ALTER TABLE `tblClassDetails` ADD `detailsStart` DATE NOT NULL DEFAULT
> 'CURDATE()' AFTER `detailsDate` ;

No.

--
David Powers
Adobe Community Expert, Dreamweaver
http://foundationphp.com