Re: Converting between INTERVAL types
Posted in 1999
Topics: General Discussion
Try the following: select ('1 02:31'::interval day to minute)::interval hour to minute from systables where tabid = 1 in a normal query: select intervalfield::interval day to minute from table where ... It worked fine with me.. Arnar ----- Original Message ----- From: Christian Allaire <callaire@ergonet.com> To: <informix-list@iiug.org> Sent: Wednesday, August 11, 1999 9:13 PM Subject: Converting between INTERVAL types > Hi, > > I would like to know if it is possible to convert > a type "interval day to minute" to an "interval hour to minute", > and is so how do you do it ? > > For example, 1 02:31 would become 26:31 > > Thanks, > > Chris > >
Arnar Birgisson wrote: > > Try the following: > > select ('1 02:31'::interval day to minute)::interval hour to minute > from systables where tabid = 1 > > in a normal query: > select intervalfield::interval day to minute from table where ... > > It worked fine with me.. This uses IUS (IDS/UDO, Foundation.2000, ...) cast notation. Alternatively: SELECT INTERVAL(0:0) HOUR TO MINUTE + INTERVAL(1 02:31) DAY TO MINUTE FROM "informix".systables WHERE tabid = 1 This should produce the correct answer for you -- the LHS of the addition seems to determine the type. > ----- Original Message ----- > From: Christian Allaire <callaire@ergonet.com> > Sent: Wednesday, August 11, 1999 9:13 PM > > I would like to know if it is possible to convert > > a type "interval day to minute" to an "interval hour to minute", > > and is so how do you do it ? > > > > For example, 1 02:31 would become 26:31 -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN #include <disclaimer.h>