Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CURDATE() as default for a MySQL field?

LEGEND ,
Mar 23, 2009 Mar 23, 2009
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
==================


TOPICS
Server side applications
6.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 23, 2009 Mar 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 23, 2009 Mar 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 23, 2009 Mar 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 23, 2009 Mar 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 23, 2009 Mar 23, 2009
LATEST
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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines