vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Greetings: I am working on a function which returns an interval value. The work of the function is to calculate the difference between the appointment timestamp and and the current timestamp, represented as an interval, and the the time required to travel from point A to B, represented as an interval. Appoint time: 01/14/2004 15:30 Current time: 01/11/2004 10:43 Appt Interval: @ 3 days 4 hours 17 mins Travel Time: 78 hours 17 minutes Travel Interval: @ 3 days 6 hours 17 mins As you can see, this truck is going to be 2 hours late. The return value I'm looking for is the difference between Appt. Interval and Travel Interval, as in: return (appt_interval - travel_interval). This value will be stored in a column of type interval. I would like for late values to be shown as negative. @ -2 hours. I thought that subtracting the larger interval from the small would return this but it is always the absolute value. The documentation states: interval values can be written with the following syntax: [@] quantity unit [quantity unit...] [direction] Where: quantity is a number (possibly signed); Considering the above statement I believed that I could show this difference as a negative value but I haven't been able to figure out how to do it. Can I do this, and if so, how? Thanks... Work: 1-336-372-6812 Cell: 1-336-363-4719 email: terry@esc1.com ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend |
| ||||
| On Tue, 11 Jan 2005, Geoffrey wrote: > Tom Lane wrote: >> Terry Lee Tucker <terry@esc1.com> writes: >> >>> Apparently, if DateStyle is set to Sql, it always returns the absolute >>> value. >>> Is this due to some Sql standard or is it a bug? >> >> >> It's a bug in interval_out. Looks like it gets it wrong for GERMAN >> style too. Surprising no one noticed before. > > Any idea when I might be able to put my hands on Red Hat 3 rpm versions that > include this fix? > > Currently running postgresql-server-7.4.6-2PGDG > and would like to stick with the same version. It'd be a whole lot easier to > apply the fix via rpm rather then having to build from source. If you really need it, you can rebuild the rpm itself from the .src.rpm. Adding a small patch is quite easy, even if you're not familiar with spec files. Usually there are other patches already, all you need is to move the patch file to the right place (SOURCES in the rpm tree) and add one PatchXXX: and one %patchXXX line. Then use rpmbuild (note that you need the development set of packages installed, of course). ..TM. -- ____/ ____/ / / / / Marco Colombo ___/ ___ / / Technical Manager / / / ESI s.r.l. _____/ _____/ _/ Colombo@ESI.it ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match |
| Thread Tools | |
| Display Modes | |
|
|