Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Timestamp comparison problem...

Andy HardySep 30 2009 — edited Oct 2 2009
I'm sure that this is a "can't see the wood for the trees" problem, but...

I have a validation routine that converts an on-page date (datepicker) to a timestamp (by adding an offset, etc.) and compares that to a timestamp in the database. If they are different, a further validation is made against the page-based timestamp.

In my test, the page-based timestamp and the database-based timestamps appear to have the same value but the comparison says that they are different.

From the validation:

DECLARE
l_db_gas_day_start customers.gas_day_start%TYPE; -- timestamp with local time zone
l_disp_gas_day_start customers.gas_day_start%TYPE;

FUNCTION show(p_in TIMESTAMP WITH LOCAL TIME ZONE) RETURN VARCHAR2 IS
l_return varchar2(4000);
BEGIN
select TO_CHAR(p_in
,'DD-MON-YYYY HH24:MI:SS:FF6 TZR')||':'||dump(p_in)
into l_return
from dual;
RETURN l_return;
END;

BEGIN

SELECT gas_day_start
INTO l_db_gas_day_start
FROM customers
WHERE id = :p2020_id;

-- routine to convert the date to a timestamp and add a predetermined hour offset
l_disp_gas_day_start := amfr_dates.apex_date_picker_gd_to_ts_ltz(:p2020_gas_day_start_disp);
--
wwv_flow.debug('P2020_ID=' || :p2020_id);
wwv_flow.debug('l_disp_gas_day_start=' || show(l_disp_gas_day_start));
wwv_flow.debug('l_db_gas_day_start=' || show(l_db_gas_day_start));

wwv_flow.debug('Dates ' || CASE WHEN
l_disp_gas_day_start = l_db_gas_day_start THEN 'Match' WHEN
l_disp_gas_day_start > l_db_gas_day_start THEN
'l_disp_gas_day_start > l_db_gas_day_start' WHEN
l_db_gas_day_start > l_disp_gas_day_start THEN
'l_db_gas_day_start > l_disp_gas_day_start' END);


My debug shows:

0.07: P2020_ID=165277684689464379483956464027546718233
0.08: l_disp_gas_day_start=02-JAN-2008 07:00:00:000000 +01:00:Typ=231 Len=7: 120,108,1,2,7,1,1
0.08: l_db_gas_day_start=02-JAN-2008 07:00:00:000000 +01:00:Typ=231 Len=7: 120,108,1,2,7,1,1
0.08: Dates l_db_gas_day_start > l_disp_gas_day_start
0.08: ...Validation did NOT pass

SO... to my mind I have two identical timestamps, but the comparison doesn't agree!

I'm sure it's a head-thwack answer, but... ideas?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 30 2009
Added on Sep 30 2009
4 comments
1,379 views