List:General Discussion« Previous MessageNext Message »
From:Gerald Clark Date:July 26 2000 1:46pm
Subject:Re: Simple question
View as plain text  
Heiko Stoermer wrote:

> AJDIN BRANDIC wrote:
> > Probably asked before but couldn't find the answer.
> > What I want to do is each time a record is added to my table, current
> > date and time should be added to the same record.
> > i.e.
> > insert into table mytable(id,name) values (1,'John Smith');
> >
> > then select * from mytable;
> >
> > should give me
> >
> > 1, John Smith, 2000-07-24 11.30
> >
> > How do I set date field to do so?
>
> I'm not sure, but I don't think that you can do this automatically. In
> other databases this would be achieved through stored procedures and
> triggers - but mysql has neither.
>
> what you can to is to expand your insert statement like this:
> insert into table mytable(id,name,datefield,timefield) values (1,'John
> Smith',CURRENT_DATE,CURRENT_TIME);
>
> this should work.
>
> greetings,
>
> heiko stoermer
>

What is wrong with a timestamp field?

Thread
Simple questionAJDIN BRANDIC26 Jul
  • Re: Simple questionHeiko Stoermer26 Jul
  • Re: Simple questionGerald Clark26 Jul
  • Re: Simple questionHeiko Stoermer26 Jul
  • Re: Simple questionRyan Wahle26 Jul
    • Re: Simple questionAJDIN BRANDIC26 Jul
      • Re: Simple questionLaszlo G. Szijarto26 Jul
        • Re: Simple questionAJDIN BRANDIC27 Jul
          • Re: Simple questionMarc Palmer27 Jul
          • Re: Simple questionMarc Palmer27 Jul
      • Re: Simple questionJim Allen26 Jul