Finding difference in minutes between 2 DateTimes
Posted in 2010
Topics: General Discussion
I'm a MS SQL guy and brand new to Informix. I'm trying to find a status time in minutes and I can't seem to figure it out. Select (current-u.status_time) as StatusMinutes from users u This works, but it gives me results as: 0 00:41:38.000 0 00:19:18.000 0 00:19:18.000 I'm just trying to get 41 19 19 Thanks for the help.
Hi J, Try Select (current-u.status_time)::INTERVAL MINUTE(8) TO MINUTE::CHAR(9)::INT as StatusMinutes from users u The Int on the end is to get it to a number (assume you need that) And the Char(9) is to get you from interval to int - there is no direct cast The Char has to be 1 longer than the interval as it takes the end character as well. The Minute(8) will allow the result to be 8 digits long (99,999,999 minutes) - trim as necessary. Jarrod Teale Fonterra NZ -----Original Message----- From: informix-list-bounces@iiug.org [mailto:informix-list-bounces@iiug.org] On Behalf Of J. Hart Sent: Friday, 15 January 2010 2:01 p.m. To: informix-list@iiug.org Subject: Finding difference in minutes between 2 DateTimes I'm a MS SQL guy and brand new to Informix. I'm trying to find a status time in minutes and I can't seem to figure it out. Select (current-u.status_time) as StatusMinutes from users u This works, but it gives me results as: 0 00:41:38.000 0 00:19:18.000 0 00:19:18.000 I'm just trying to get 41 19 19 Thanks for the help. _______________________________________________ Informix-list mailing list Informix-list@iiug.org http://www.iiug.org/mailman/listinfo/informix-list DISCLAIMER: This email contains confidential information and may be legally privileged. If you are not the intended recipient or have received this email in error, please notify the sender immediately and destroy this email. You may not use, disclose or copy this email or its attachments in any way. Any opinions expressed in this email are those of the author and are not necessarily those of the Fonterra Co-operative Group. http://www.fonterra.com/
Thanks Jarrod, That worked. On Jan 14, 5:12 pm, "Jarrod Teale" <Jarrod.Te...@fonterra.com> wrote: > Hi J, > Try > Select (current-u.status_time)::INTERVAL MINUTE(8) TO > MINUTE::CHAR(9)::INT as StatusMinutes from users u > > The Int on the end is to get it to a number (assume you need that) > And the Char(9) is to get you from interval to int - there is no direct > cast > The Char has to be 1 longer than the interval as it takes the end > character as well. > The Minute(8) will allow the result to be 8 digits long (99,999,999 > minutes) - trim as necessary. > > Jarrod Teale > Fonterra NZ > > > > -----Original Message----- > From: informix-list-boun...@iiug.org > > [mailto:informix-list-boun...@iiug.org] On Behalf Of J. Hart > Sent: Friday, 15 January 2010 2:01 p.m. > To: informix-l...@iiug.org > Subject: Finding difference in minutes between 2 DateTimes > > I'm a MS SQL guy and brand new to Informix. > > I'm trying to find a status time in minutes and I can't seem to figure > it out. > > Select (current-u.status_time) as StatusMinutes from users u > > This works, but it gives me results as: > 0 00:41:38.000 > 0 00:19:18.000 > 0 00:19:18.000 > > I'm just trying to get > 41 > 19 > 19 > > Thanks for the help. > _______________________________________________ > Informix-list mailing list > Informix-l...@iiug.orghttp://www.iiug.org/mailman/listinfo/informix-list > > DISCLAIMER: > This email contains confidential information and may be legally privileged. If you are not the intended recipient or have received this email in error, please notify the sender immediately and destroy this email. > You may not use, disclose or copy this email or its attachments in any way. > Any opinions expressed in this email are those of the author and are not necessarily those of the Fonterra Co-operative Group.http://www.fonterra.com/- Hide quoted text - > > - Show quoted text -