Re: Date arithmetic in Informix Online 5.0
Posted in 2000
Zack Hamm wrote: > > I'm trying to do some basic date math in informix online. I have a > table with a column called 'access_date' which has a date column stored > as '20000702' for todays date. I'd like to be able to generate queries > where I can say "look at all events which have happened XX days from > today". (e.g. 20000702-90 would be 3 months ago) > I know in mysql there is a command called DATE_SUB which does this, is > there an equivalent in informix, particularly in Online version 5? (I > know, I know, it's an OLD version, but the customer won't upgrade). The DATE data type hasn't changed over the versions. If you were using DATE, then DATE - 90 would be easy. If you are storing that date as a CHAR, then you are making your life unnecessarily complicated. There are date functions to help, like DATE() and MDY(), but if you can convert to the DATE data type you will save yourself some time and storage. Cheers, -- Mark. +----------------------------------------------------------+-----------+ | Mark D. Stock mailto:mdstock@mydas.freeserve.co.uk |//////// /| | http://www.informix.com http://www.informixhandbook.com |///// / //| | http://www.iiug.org +-----------------------------------+//// / ///| | |This email will self-destruct in |/// / ////| | |10 sec. If you received this email |// / /////| | |in error, sorry about the mess. |/ ////////| +----------------------+-----------------------------------+-----------+