From: | "David Loh" <david(at)bizsurf(dot)com> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | A minute in timestamp |
Date: | 2003-05-08 06:40:22 |
Message-ID: | 003501c3152c$b3872a30$f92c2c0a@david |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi all.
After some read of postgres' documentations, I can't found any command perform similar task like timediff() in other SQL server, the only thing I got is date_part().
For my case, what I actually need is to create a trigger (before insert) that check previous record (1 mins), grab the previous value and deduct new value (NEW.myValue := Previous.myValue - NEW.myOtherValue), and since the records are insert every minutes,the function should trace back to the record entered a minute ago (for e.g, 12:38 will check for record of 12:37 and grab the value), hence timestamp even include the milli-second, is there any command/trick to check if the record are entered approximately 55-65 secs (1 minutes +/- 5 secs) ?
So far, I'd tried 'select * from myTable where date_part('minute',Update_Time - now()) = 1;', but this SQL statement will only return result if the hour:minute:milli-seconds MATCH EXACTLY !! (12:38.51451->12:39.51451 = match, the rest aren't). Then I switch to 'select * from myTable where Update_Time = now()-interval '1 minute'', but it still the same :(
If any of you guys have a solution to solve my problems, please kindly let me know, your help is greatly apprepriate.
Thanks in advance.
Regards,
David Loh
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2003-05-08 07:24:03 | Re: A minute in timestamp |
Previous Message | Rajesh Kumar Mallah | 2003-05-08 06:15:26 | seeing type defination.. |