Thread: TODAY and CURRENT?
I have a table with columns datetime timestamp, value float(8) I want to delete rows 10 days older or 10 hours older by delete from tablename where datetime < TODAY-10; or delete from tablename where datetime between CURRENT-10 and CURRENT; So are there key words TODAY, CURRENT in PostgreSQL? Thank you!
Attachment
Hi Raymond, You might try something like this: DELETE FROM tablename WHERE datetime < ('now'::timestamp - '10 days'::interval); and DELETE FROM tablename WHERE datetime BETWEEN ('now'::timestamp - '10 hours'::interval) AND 'now'::timestamp; If you just want the date stamp, you can use 'now'::date instead of your TODAY. If you want date-and-time stamp, use 'now'::timestamp - this would match your idea of CURRENT. Hope this helps Francis Solomon > > I have a table with columns > > datetime timestamp, > value float(8) > > I want to delete rows 10 days older or 10 hours older by > > delete from tablename where datetime < TODAY-10; > or > delete from tablename where datetime between CURRENT-10 and CURRENT; > > So are there key words TODAY, CURRENT in PostgreSQL? > > Thank you! >
On Tue, Dec 19, 2000 at 10:37:42AM -0500, Raymond Chui wrote: > delete from tablename where datetime < TODAY-10; delete from tablename where datetime < timestamp 'now' - interval '10 days'; or delete from tablename where age(datetime) > '10 days'; -- Mike Castle Life is like a clock: You can work constantly dalgoda@ix.netcom.com and be right all the time, or not work at all www.netcom.com/~dalgoda/ and be right at least twice a day. -- mrc We are all of us living in the shadow of Manhattan. -- Watchmen
Hey Guys, This is probably a trivial question to most but I can't figure it out. I am doing a previous button and I need to select the record that has a lower comment id than the current one. The problem is I cant use commentid-1 becuase the commentid's are not incremented by one each time but by different numbers. I also cant use the following: $sql = "select threadid, commentid, name, detail from comments where commentid < '$commentid' and threadid='$threadid'"; because it gets the lowest value comment whereas what I want is the highest value comment but lower that $commentid (so basically the one immediately below this one). Any help would be appreciated, Thanks, Abe