Re: Help! SQL example needed for date comparison!

From: Jonathan Leffler <johnl_at_informix.com>
Date: 1997/12/02
Message-ID: <662hrv$19u_at_cssun.mathcs.emory.edu>#1/1


On Wed, 26 Nov 1997 ah262_at_detroit.freenet.org wrote:

} I am old-time "Big Iron" programmer, new to SQL and the Informix
} relational database, and am in need of some _simple_ sample code.
}
} I am in urgent need of some SQL sample code that takes a database
} DATETIME formatted field and compares it to the system date (minus one
} day) for equality.

Assuming that the DATETIME field is called PriorDate and is of type DATETIME YEAR TO DAY (or includes some time too), then you should be able to write:

        PriorDate = TODAY - 1

If that doesn't work, you can force 'TODAY - 1' into a DATETIME using

        PriorDate = EXTEND(TODAY - 1, YEAR TO DAY)

I haven't formally checked these, so I could be wrong. Also:

        PriorDate = CURRENT YEAR TO DAY - 1 UNITS DAY

That should work regardless...

} I am, in effect, attempting to pull the records from
} a table dated 1 day previous from the current system date. Sounds
} simple, eh? I've looked at using the various date functions that Informix
} provides, but each one is very specialized in the resulting value it
} produces.
}
} Unfortunately, all I have available to me is the Informix tutorial,
} reference, and syntax manuals, and none of these even come remotely close
} to defining the code for such a simple task.

Informix Guide to SQL: Reference, chapter on data types probably covers this.

} Any help you can provide would be most appreciated on this. If you know
} of any good SQL tutorial books with Informix hooks shown in it I would
} also appreciate knowing about those.

Yours,
Jonathan Leffler (johnl_at_informix.com) #include <witticism.h> Received on Tue Dec 02 1997 - 00:00:00 CET

Original text of this message