I am trying to work with the date (timestamp to be precise) and getting into trouble. My requirement is below.
I have a stage table where the data is stored as JSON in a Variant Column and the data looks like below in that column.
{ “message_body”: { “campus_code”: “TEST”, “campus_name”: “TEST”, “event_type”: “TEST”, “location_code”: “A00000”, “location_name”: “TEST”, “order”: { “credit_total”: 0, “app_version”: “1.0.9”, “asap”: 1, “complete_datetime”: “2020-11-19 00:08:20” } “timezone_offset_minutes”: -360, } }
I have below requirement
Convert the Datetime into only Date, so i tried the 2 below queries
select trunc(to_date(body:message_body:order:complete_datetime), 'DAY') FROM "stage_table";
select date_trunc('DAY', to_date(body:message_body:order:complete_datetime)) FROM "stage_table";
The source date is "2020-11-19 00:08:20" and both the queries return the output as "2020-11-19 00:00:00" even though my expected value should be in the form of "YYYY-MM-DD".
Any help is highly appreciated
Thanks
Aravind N