Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Finding difference in minutes between 2 DateTimes

72 views
Skip to first unread message

J. Hart

unread,
Jan 14, 2010, 8:00:40 PM1/14/10
to
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.

Jarrod Teale

unread,
Jan 14, 2010, 8:12:35 PM1/14/10
to inform...@iiug.org
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

Thanks for the help.
_______________________________________________
Informix-list mailing list
Inform...@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/

J. Hart

unread,
Jan 19, 2010, 10:29:18 AM1/19/10
to
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 -

0 new messages