informix - Case,Substring and concat within a cognos Data Item Expression -


i'm scratching head trying work time functions within cognos 10.2.1 (report studio), using informix db data source.

my time field stored smallint, 4 digits, representing 24 hour clock. trying time display 6:00pm, 11:30am, 3:00pm, etc. have separate data expression calculates string 'am' or 'pm' depending on hour value, i'm running errors when doing overall concat/substring function.

case when char_length([query1].[beg_tm]) = 4  (substring(cast([starttime], char(5)), 1, 2)) || ':' || (substring   (cast   ([starttime], char(5)), 3, 2))  || ([beg_ampmcalc]) when char_length([query1].[beg_tm]) = 3 (substring(cast([starttime], char(5)), 1, 1)) || ':' || (substring(cast    ([starttime], char(5)), 3, 2))  || ([beg_ampmcalc]) else '--' end   

why not use datetime hour minute; @ least have deal converting 24 hour clock 12 hour clock. midnight stored 0 , noon 1200, , minute before midnight 2359? cognos uses modern version of informix, believe, should able use to_char function:

drop table if exists times; create temp table times(p_time smallint); insert times values(0); insert times values(59); insert times values(100); insert times values(845); insert times values(1159); insert times values(1200); insert times values(1259); insert times values(1300); insert times values(1815); insert times values(2359);  select to_char(current hour minute, "%i:%m %p"),        p_time,        datetime(00:00) hour minute + mod(p_time, 100) units minute + (p_time/100) units hour,        to_char(datetime(00:00) hour minute + mod(p_time, 100) units minute + (p_time/100) units hour, "%i:%m %p")   times; 

output:

03:49      0   00:00   12:00 03:49     59   00:59   12:59 03:49    100   01:00   01:00 03:49    845   08:45   08:45 03:49   1159   11:59   11:59 03:49   1200   12:00   12:00 pm 03:49   1259   12:59   12:59 pm 03:49   1300   13:00   01:00 pm 03:49   1815   18:15   06:15 pm 03:49   2359   23:59   11:59 pm 

i'm using database server has local time set utc, , i'm in time zone -07:00 (us/pacific); current time isn't middle of night am.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -