Page 1 of 1

need help in automatic update

Posted: Mon Jun 23, 2008 5:15 am
by ali560045
i have created a table with the system date as one of the column:

create table nav_date as (SELECT TO_CHAR(SYSDATE, 'DD-MON-YYYY HH:MI:SS') "Current date" FROM dual)

------------------------------------------------------

how to get the current system date in the table whenever i select * the table nav_date?

Re: need help in automatic update

Posted: Mon Jun 23, 2008 11:39 am
by Christopher
You need to UPDATE that field each time or use a function rather than store the date.

Re: need help in automatic update

Posted: Mon Jun 23, 2008 12:34 pm
by califdon
ali560045 wrote:i have created a table with the system date as one of the column:

create table nav_date as (SELECT TO_CHAR(SYSDATE, 'DD-MON-YYYY HH:MI:SS') "Current date" FROM dual)

------------------------------------------------------

how to get the current system date in the table whenever i open the table nav_date?
As arborint said, you don't need to store the date in the table if you're just going to update it every time you look at the record. And by the way, you don't ever "open" a table, as you would a file. You merely access the data in a table, so there is no "open" event associated with a table.

Re: need help in automatic update

Posted: Tue Jun 24, 2008 1:32 am
by ali560045
so can anyone help me getiing the function defined here instead of storing the date in the table.

i think thats the only way of solving this problem.

thanks for the above replies

Re: need help in automatic update

Posted: Tue Jun 24, 2008 11:42 am
by califdon
The current system date is always available simply as date(). Just use that expression in your PHP code when you want the current system date. http://www.w3schools.com/PHP/php_date.asp

If you are talking about some other date, such as the date a particular record was added or modified, that's an entirely different question, but you indicated you wanted to know the current date/time whenever you accessed a table.