Great, this is more of what I was looking for....a way to have the DB auto
populate the date/time in a column, without having to use sql.

Thanks again!


                                                                                       
                            
                    "Uttam"                                                            
                            
                    <[EMAIL PROTECTED]       To:     <[EMAIL PROTECTED]>, <[EMAIL 
PROTECTED]>                  
                    in>                  cc:                                           
                            
                                         Subject:     RE: Newbie - How can I insert 
new data with the current      
                    03/16/2003            date/time?                                   
                            
                    02:10 AM                                                           
                            
                                                                                       
                            
                                                                                       
                            




*if you create a column of the type TIMESTAMP instead of DATETIME then it
automatically stores the time when the record was inserted/last updated.  If
you have more that one column of type TIMESTAMP in the same table then only
the first TIMESTAMP column gets updated automatically. (Don't confuse MySQL
TIMESTAMP column type with Unix Timestamp, MySQL TIMESTAMP column is just an
automatically updated DATETIME column)

*to insert current datetime in a DATETIME column, use NOW() or SYSDATE().
e.g.
INSERT INTO bug_master VALUES (1, "Timothy", NOW())

regards,

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Saturday, March 15, 2003 20:08
To: [EMAIL PROTECTED]
Subject: Newbie - How can I insert new data with the current date/time?


I have a table called animals (using the example in the MySQL guide). I
have a
datetime column type.
Here is the table:
create table bug_master (
               id MEDIUMINT NOT NULL AUTO_INCREMENT,
               name CHAR(30) NOT NULL,
               date DATETIME NOT NULL,
               PRIMARY KEY (id)
          );

I want to do a simple insert into the table with the current date and
time, i.e.
the system date.
I'm having some problems finding the correct sql syntax to do this.
Could anyone
help with this?
Do I need a Now() function?

insert into animals <the rest of the query??>;

Thanks!
Kevin








---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to