RE: sysdate or curdate as default date in mysql

2002-09-02 Thread Mike Hillyer

If what you are looking for is the current date to be used as date of
creation, then remain unchanged, you will have to specify sysdate as a value
during an insert. You may benefit from the timestamp datatype, which sets
itself to the current date when any DML statements (insert, update) are
performed.

Mike


-Original Message-
From: Chugh Shalini [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 02, 2002 6:41 AM
To: [EMAIL PROTECTED]
Subject: sysdate or curdate as default date in mysql


Dear All!
Can we define sysdate or curdate as default date for a column of
datatype 'date' while creating a table?

Regards

Sql, mysql, query


-
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



-
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: sysdate or curdate as default date in mysql

2002-09-02 Thread DL Neil

Dear Chugh,

 Can we define sysdate or curdate as default date for a column of
 datatype 'date' while creating a table?


The question is ambiguous:

- if a table is created with a column defined to be a TIMESTAMP data type,
then every time a row is INSERTed or UPDATEd, the current date will be
entered into the field (a two-edged sword!).

- if you want to define the date/time under which MySQL is running, eg run
it as if the server was in London instead of India, then the way to do that
is to run the whole serverPC with such a system clock setting.

- if you want the table's creation date/time to be the default value for a
particular column, then I think you will have to hard-code that as a literal
value into the column definition within CREATE TABLE (I don't think it is
possible to ask MySQL to evaluate and plug in the time value for you)

Have you studied the manual?
Regards,
=dn



-
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: sysdate or curdate as default date in mysql

2002-09-02 Thread Egor Egorov

Chugh,
Monday, September 02, 2002, 3:41:27 PM, you wrote:

CS Can we define sysdate or curdate as default date for a column of
CS datatype 'date' while creating a table?

You can't define result of function as a default value.
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/
   __  ___ ___   __
  /  |/  /_ __/ __/ __ \/ /Egor Egorov
 / /|_/ / // /\ \/ /_/ / /__   [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: sysdate or curdate as default date in mysql

2002-09-02 Thread Chugh Shalini

Thankx for the reply Egorov,Hillyer and Neil. 
Timestamp has solved my purpose.

Actually we are porting an application from oracle to mysql. In Oracle there
were some tables which were using sysdate as default date, therefore we
wanted something similar functionality, as it was very difficult to make
changes in code of such a large application 

According to Neil my question was little ambiguous, but inspite of that the
answers replied by all of you had helped me in solving my query.




-Original Message-
From:   Egor Egorov [SMTP:[EMAIL PROTECTED]]
Sent:   Monday, September 02, 2002 9:31 PM
To: [EMAIL PROTECTED]
Subject:Re: sysdate or curdate as default date in mysql

Chugh,
Monday, September 02, 2002, 3:41:27 PM, you wrote:

CS Can we define sysdate or curdate as default date for a
column of
CS datatype 'date' while creating a table?

You can't define result of function as a default value.
Take a look at TIMESTAMP column type:
 http://www.mysql.com/doc/en/DATETIME.html

 -Original Message-
 From: Mike Hillyer [SMTP:[EMAIL PROTECTED]]
 Sent: Monday, September 02, 2002 6:54 PM
 To:   Chugh Shalini; [EMAIL PROTECTED]
 Subject:  RE: sysdate or curdate as default date in mysql
 
 If what you are looking for is the current date to be used as date of
 creation, then remain unchanged, you will have to specify sysdate as a
 value
 during an insert. You may benefit from the timestamp datatype, which sets
 itself to the current date when any DML statements (insert, update) are
 performed.
 
 Mike
 
 
-Original Message-
From:   DL Neil [SMTP:[EMAIL PROTECTED]]
Sent:   Monday, September 02, 2002 7:15 PM
To: Chugh Shalini; [EMAIL PROTECTED]
Subject:Re: sysdate or curdate as default date in mysql

Dear Chugh,

 Can we define sysdate or curdate as default date for a column of
 datatype 'date' while creating a table?


The question is ambiguous:

- if a table is created with a column defined to be a TIMESTAMP data
type,
then every time a row is INSERTed or UPDATEd, the current date will
be
entered into the field (a two-edged sword!).

- if you want to define the date/time under which MySQL is
running, eg run
it as if the server was in London instead of India, then the way to
do that
is to run the whole serverPC with such a system clock setting.

- if you want the table's creation date/time to be the default value
for a
particular column, then I think you will have to hard-code that as a
literal
value into the column definition within CREATE TABLE (I don't think
it is
possible to ask MySQL to evaluate and plug in the time value for
you)

Have you studied the manual?
Regards,
=dn

 -Original Message-
 From: Chugh Shalini [mailto:[EMAIL PROTECTED]]
 Sent: Monday, September 02, 2002 6:41 AM
 To: [EMAIL PROTECTED]
 Subject: sysdate or curdate as default date in mysql
 
 
 Dear All!
   Can we define sysdate or curdate as default date for a column of
 datatype 'date' while creating a table?
 
 Regards
 
 Sql, mysql, query
 
 
 -
 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
 
 
 
 -
 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

-
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