If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > Datetime conversion

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-28-04, 12:27
tachek tachek is offline
Registered User
 
Join Date: Jul 2004
Posts: 1
Datetime conversion

I'm trying to calculate the amount of minutes between two datetime variables. I want the final result to be an integer, but I don't know the syntax to use in Informix.

Any help is appreciated.
Reply With Quote
  #2 (permalink)  
Old 07-29-04, 12:00
gurey gurey is offline
Registered User
 
Join Date: Aug 2003
Location: Argentina
Posts: 780
Hi,

Please test with function extend(datetime, year to minute).

Gustavo.
Reply With Quote
  #3 (permalink)  
Old 08-26-04, 02:51
debindranil debindranil is offline
Registered User
 
Join Date: Aug 2004
Posts: 10
Hi,
You can use INTERVAL datatype to calculate the time difference in the following way.

DEFINE v1 DATETIME year to second;
DEFINE v2 DATETIME year to second;

DEFINE var1 INTERVAL hour to second

LET var1 = v2 - v1

With Regards,

ID
Reply With Quote
  #4 (permalink)  
Old 08-26-04, 11:30
iaguigon iaguigon is offline
Registered User
 
Join Date: May 2004
Location: Barcelona, Spain
Posts: 54
interval to integer

Quote:
Originally Posted by tachek
I'm trying to calculate the amount of minutes between two datetime variables. I want the final result to be an integer, but I don't know the syntax to use in Informix.

Any help is appreciated.
I've never known how to convert an interval to an integer directly... however, this is the way I managed to do it:

define dt1 datetime year to second;
define dt2 datetime year to second;
define iv1 interval minute(9) to minute;
define number1 integer;

let dt1 and dt2 get whatever values are needed;

let iv1 = dt1 - dt2;
let number1 = iv1::char(10);

variable number1 gets the number of minutes passed between dt2 and dt1, which I assume you will like to use in some math expressions afterwards (if not, you could stick to the interval-type variable!)

hope this helps
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On