Re: hour, minute and week functions
Posted in 1998
dennisp@informix.com wrote: >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] Ok. This will work. BUT, the above example (using EXTEND) is returning 13 too. And, I'll use HOUR(7) TO HOUR only while extending INTERVAL values (not DATETIME values). The EXTEND function is working quite well in SQL. You don't need any temp table manipulations for this kind of work (IMHO). Kind Regards, Octav > >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 > -- Octav Chiriac Phone: (373) 2 21 20 96 NetInfo S.R.L. Fax: (373) 2 21 36 59 Chisinau (373) 2 24 00 83 Moldova, Republic of mailto:com@netinfo-moldova.com