Re: Universal Web Connect and DATE fields
Posted in 1998
On Thu, 20 Aug 1998 14:09:49 +0200, "Eduardo Quint's" <quintas@udc.es> wrote: >When we retrieve date fields from a <?MISQL> tag, Universal Web Connect >expands it to dd/mm/yy format in html document. >We need display dd/mm/yyyy format. > >Does anyone know any variable/function ... to solve it ? I use 'Web Datablade' that comes with Informix Universal Server; I think UWC is somehow different (more advanced?) but anyway.. something like this (uses 50-year window around 2000) <?MISQL SQL="select the_date from the_table;"> $(SUBSTR,$1,1,7)/ $(IF,$(EQ,$(SUBSTR,$1,8,1),1),20) $(IF,$(EQ,$(SUBSTR,$1,8,1),2),20) $(IF,$(EQ,$(SUBSTR,$1,8,1),3),20) $(IF,$(EQ,$(SUBSTR,$1,8,1),4),20) $(IF,$(EQ,$(SUBSTR,$1,8,1),5),19) $(IF,$(EQ,$(SUBSTR,$1,8,1),6),19) $(IF,$(EQ,$(SUBSTR,$1,8,1),7),19) $(IF,$(EQ,$(SUBSTR,$1,8,1),8),19) $(IF,$(EQ,$(SUBSTR,$1,8,1),9),19) $(IF,$(EQ,$(SUBSTR,$1,8,1),0),20) $(SUBSTR,$1,8,2) <?/MISQL> -- -$1 is the first column retrieved for the query; -text and code between <?MISQL> and <?/MISQL> is processed for each record returned (once with nulls when no data is available) - there's no way to convert the substringed decade-value to an int, which would be the only way to pick the era out of an array. -exercises for the reader: -figure out how null records are detected without producing exceptions -get the current year so as to have a floating 50-year window *** Free sample: *** validate a date: In: MMI_VALID year_date_birth month_date_birth day_date_birth Out: MMI_VALID MMI_VALDATE <?MIBLOCK COND=$(EQ,$MMI_VALID,TRUE)> <?MIVAR NAME=MMI_VALDATE>TRUE<?/MIVAR> <?MIVAR COND=$(NOT,$(ISINT,$year_date_birth)) NAME=MMI_VALID>FALSE<?/MIVAR> <?MIVAR COND=$(ISINT,$year_date_birth)> $(IF,$(<,$year_date_birth,1900),$(SETVAR,$MMI_VALID,FALSE)) <?/MIVAR> <?MIVAR COND=$(NOT,$(ISINT,$month_date_birth)) NAME=MMI_VALID>FALSE<?/MIVAR> <?MIVAR COND=$(ISINT,$month_date_birth)> $(IF,$(<,$month_date_birth,1),$(SETVAR,$MMI_VALID,FALSE)) <?/MIVAR> <?MIVAR COND=$(ISINT,$month_date_birth)> $(IF,$(NOT,$(<,$month_date_birth,13)),$(SETVAR,$MMI_VALID,FALSE)) <?/MIVAR> <?MIVAR COND=$(NOT,$(ISINT,$day_date_birth)) NAME=MMI_VALID>FALSE<?/MIVAR> <?MIVAR COND=$(ISINT,$day_date_birth)> $(IF,$(<,$day_date_birth,1),$(SETVAR,$MMI_VALID,FALSE)) <?/MIVAR> <?MIBLOCK COND=$(AND,$(ISINT,$day_date_birth),$(ISINT,$month_date_birth))> <?MIVAR COND=$(AND,$(<,0,$day_date_birth), $(<,$month_date_birth,13), $(<,0,$month_date_birth))> $(IF, $(<, $(NTH,$month_date_birth, 0,31, $(IF,$(=,$(/,$year_date_birth,4),$(FIX,$(/,$year_date_birth,4))), $(IF,$(=,$(/,$year_date_birth,100),$(FIX,$(/,$year_date_birth,100))), $(IF,$(=,$(/,$year_date_birth,400),$(FIX,$(/,$year_date_birth,400))), 29, 28), 29), 28), 31,30,31,30,31,31,30,31,30,31),$day_date_birth), $(SETVAR,$MMI_VALID,FALSE) ) <?/MIVAR> <?/MIBLOCK> <?MIVAR COND=$(EQ,$MMI_VALID,FALSE)>$(SETVAR,$MMI_VALDATE,FALSE)<?/MIVAR> <?/MIBLOCK> John