Re: hour, minute and week functions
Posted in 1998
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
In article <70padr$jd5$1@news.xmission.com>, Octav Chiriac <com@netinfo-moldova.com> wrote: > T.K. Anand wrote: > >Informix has Time functions for YEAR, MONTH, DAY but none for WEEK, HOUR, > >MINUTE, SECOND. How does one extract the HOUR out of a datetime column ? > > > > EXTEND(DATETIME(1998-01-01 13:48) YEAR TO MINUTE, HOUR TO HOUR) > I think you'd probably want something like HOUR(7) TO HOUR, to make sure your datetime doesn't exceed boundries. This also will return a datetime that is the number of hours since year 0. An HOUR extension that would work like YEAR, MONTH, or DAY would return the number of hours for the given day. The original post needs to be more specific. If for the string "1998-01-01 13:48", you want "13" returned, you can subscript in 4GL: LET charVariable = datetimeVariable LET intVariable = charVariable[12,13] The SQL solution takes some temp table manipulation (to convert the CHAR into a numeric), but it can be done. This assumes you want an number (smallint or integer) returned. You could also return an INTERVAL, which is a span between two DATETIMEs. I'm shooting from the hip here, which means my foot will probably end up in my mouth. Dennis J Pimple Informix Software, Inc. Denver, CO, USA -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own