Unix Technical Forum

Re: days between dates

This is a discussion on Re: days between dates within the Informix forums, part of the Database Server Software category; --> Bill Hamilton wrote: > Yes, they are datetime year to second. > date1 - date2 returns an "interval" So ...


Go Back   Unix Technical Forum > Database Server Software > Informix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 07:30 PM
Jonathan Leffler
 
Posts: n/a
Default Re: days between dates

Bill Hamilton wrote:

> Yes, they are datetime year to second.
> date1 - date2 returns an "interval"



So convert them to DATE before subtracting:

SELECT DATE(dtime1) - DATE(dtime2) ...


> ----- Original Message -----
> From: "John Carlson" <john_carlson@whsmithusa.com>
>
>>On Fri, 22 Aug 2003 10:04:27 -0500, "Bill Hamilton" <bham@finsco.com>
>>wrote:
>>> GlacierI would like to select into a temp table the number of
>>> days between 2 dates, but that gives an INTERVAL type. Is there
>>> anyway to get that as an INT? (in IDS 7.31)
>>>
>>>I suppose one could use the month,day,year functions.
>>>Is that the only way?
>>>

>>
>>Strange . . . . .
>>date1=9/9/03
>>date2=9/13/03
>>both are defined as date
>>
>>select (date2-date1)
>>from jctmp1
>>
>>returns: 4
>>
>>those two dates that you mentioned . . . . are they datetime instead
>>of date?



--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:25 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com