Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date- updating records

Status
Not open for further replies.

teroy

Programmer
Oct 17, 2000
67
0
0
AU
hi there..

if i wanted to automatically add the date for when a record was inserted i would use the following in my schema

my_date date default now()

does anyone know what the equivalent is if i wanted to have a field which gave the current date every time a record is updated?

Thanks in advance

troy
 
i think if you don't specify the field when you do the update then the date will be set to now() when you do the update.

i've done this in mysql (shame) but not in postgres but it should work.

Steve
 
unfortunately it doesn't :(
create table crap (me datetime default now(),hey int ) ;
insert into crap (hey) values (1) ;
libsonline=> select * from crap ;
me | hey
------------------------+-----
2001-09-18 11:57:01+10 | 1
(1 row)
libsonline=> update crap set hey=2 ;
libsonline=> select * from crap ;
me | hey
------------------------+-----
2001-09-18 11:57:01+10 | 2
(1 row)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top