My Oracle Support Banner

Time Fraction Is Lost From Date When Extracting Date Field From JSON Object (Doc ID 2560116.1)

Last updated on JUNE 30, 2019

Applies to:

Oracle Database - Enterprise Edition - Version 12.2.0.1 and later
Information in this document applies to any platform.

Symptoms

Time fraction is lost from date when extracting date field from JSON object

Example:

 

DECLARE
request json_object_t;
v_char VARCHAR2( 240 );
v_date DATE;
BEGIN
dbms_output.enable( NULL );
request := json_object_t('{"date":"2019-04-18T03:31:51"}');
v_char := request.get_String(key => 'date');
v_date := request.get_date(key => 'date');
dbms_output.put_line( 'v_date = ' || to_char(v_date, 'dd.mm.yyyy hh24:mi:ss'));
dbms_output.put_line( 'v_char = ' || to_char(v_char));
dbms_output.put_line( 'Expicit conversion :' );
dbms_output.put_line( 'v_date = ' || to_char(TO_DATE( request.get_String(key => 'date'), 'yyyy-mm-dd"T"hh24:mi:ss'), 'dd.mm.yyyy hh24:mi:ss')) ;
END;

Output :
v_date = 18.04.2019 00:00:00
v_char = 2019-04-18T03:31:51
Expicit conversion :
v_date = 18.04.2019 03:31:51

in variable v_date time is set to zero - it is wrong

Changes

 

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
Changes
Cause
Solution


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.