Identify and Fix bad Transaction Times

From KeystoneIntranet
Jump to navigation Jump to search

How to update bad times in inventory transactions. Some programs do not properly protect HHMM to ensure hours are between 00 and 23 and minutes between 00 and 59.

Diagnose bad times:

select *
from artprtrx
where (cast(trx_time / 100 as integer) > 23) or (cast(mod(trx_time, 100) as integer) > 59)

Diagnose bad times with sample fixes:

select 
trx_time, 100*(trx_time/100) "Hrs",
trx_time - 100*(trx_time/100) "Wrong Min",
100*(trx_time/100)+59 "New Time"
 from artprtrx 
where
trx_time - 100*(trx_time/100) >59

Update minutes >59:

update artprtrx
set trx_time = 100*(trx_time/100)+59
where
trx_time - 100*(trx_time/100) >59
and trx_date >= :"Starting"

Update times >2359:

update artprtrx
set trx_time = 2359
where
trx_time >2359
and trx_date >= :"Starting"