Professional Web Applications Themes

days between dates - Informix

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? sending to informix-list...

  1. #1

    Default days between dates


    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?

    sending to informix-list
    Bill Hamilton Guest

  2. #2

    Default Re: days between dates

    On Fri, 22 Aug 2003 10:04:27 -0500, "Bill Hamilton" <bhamfinsco.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?
    John Carlson Guest

  3. #3

    Default Re: days between dates

    perhaps this sql could help:

    select date1 - date2
    from table

    hth
    danny

    "Bill Hamilton" <bhamfinsco.com> wrote in message
    news:bi5btn$1rj$1terabinaries.xmission.com...
    >
    > 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?
    >
    > sending to informix-list

    Danny De Koster Guest

  4. #4

    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_carlsonwhsmithusa.com>
    >
    >>On Fri, 22 Aug 2003 10:04:27 -0500, "Bill Hamilton" <bhamfinsco.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: [email]jlefflerearthlink.net[/email], [email]jlefflerus.ibm.com[/email]
    Guardian of DBD::Informix v2003.04 -- [url]http://dbi.perl.org/[/url]

    Jonathan Leffler Guest

  5. #5

    Post Re: days between dates

    I have found a good solution on the site below. Works like charm for me.

    http://phphelp.co/2012/03/28/how-to-print-all-the-months-and-years-between-two-dates-in-php/
    aneeq Guest

Similar Threads

  1. #39560 [NEW]: Inconsistent behaviour of strtotime when days > days in month
    By php at colin dot guthr dot ie in forum PHP Bugs
    Replies: 1
    Last Post: November 20th, 05:21 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139