re: default date time insertion in the database

2002-09-26 Thread Victoria Reznichenko

Daya,
Thursday, September 26, 2002, 7:53:46 AM, you wrote:

DKD can anyone tell me how can i set the default datetime as current datetime in
DKD the mysql. so that every time i insert a record in the table current
DKD datetime automaticall inserted.
DKD Thanks in advance.

Take a look at TIMESTAMP column type:
 http://www.mysql.com/doc/en/DATETIME.html


-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___ ___   __
  /  |/  /_ __/ __/ __ \/ /Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
   ___/   www.mysql.com





-
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




Re: default date time insertion in the database

2002-09-26 Thread Josh Trutwin

 Hi,

 can anyone tell me how can i set the default datetime as current
 datetime in the mysql. so that every time i insert a record in the table
 current datetime automaticall inserted.
 Thanks in advance.

From MySQL manual section 6.5.3:

Default values must be constants. This means, for example, that you
cannot set the default for a date column to be the value of a function
such as NOW() or CURRENT_DATE.

You have a couple options though, you can use a TIMESTAMP field which will
be set to the current date/time when the data is inserted.  But if the
data changes, the timestamp field is updated again, so this will only work
if you can be certain that you will not be updating the data after
insertion.

The other option is to use a DATETIME type column and use the following
insert query:

INSERT INTO mytable (col1, col2, ... , date_inserted) VALUES ('col1data',
'col2data', ... , NOW());

Josh





-
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




default date time insertion in the database

2002-09-25 Thread Daya Krishan Dubey

Hi,

can anyone tell me how can i set the default datetime as current datetime in
the mysql. so that every time i insert a record in the table current
datetime automaticall inserted.
Thanks in advance.

Regards
Daya Krishan Dubey
Core Solucomm Ltd
423 B, Hamilton court
DLF phase IV
Gurgaon, India
Ph# 91-124-6392896/7 (O)
Mobile# 91-9811294209



-
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