need help in automatic update

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ali560045
Forum Newbie
Posts: 3
Joined: Mon Jun 23, 2008 5:14 am

need help in automatic update

Post 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?
Last edited by ali560045 on Tue Jun 24, 2008 1:31 am, edited 1 time in total.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: need help in automatic update

Post by Christopher »

You need to UPDATE that field each time or use a function rather than store the date.
(#10850)
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: need help in automatic update

Post 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.
ali560045
Forum Newbie
Posts: 3
Joined: Mon Jun 23, 2008 5:14 am

Re: need help in automatic update

Post 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
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: need help in automatic update

Post 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.
Post Reply