โ02-03-2021 06:07 AM
Hello,
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,
โorder_datetimeโ: โ2021-01-08 18:19:34โ
}
โtimezone_offset_minutesโ: -360,
}
}
I have below requirements.
select TO_TIMESTAMP((body:message_body:order:order_datetime), โyyyy-mm-dd HH24:MI:SSโ) FROM โstage_tableโ. its failing with below error message
SQL compilation error: error line 1 at position 7 too many arguments for function [TO_TIMESTAMP(GET(GET(GET(stage_table.BODY, โmessage_bodyโ), โorderโ), โorder_datetimeโ), โyyyy-mm-dd HH24:MI:SSโ)] expected 1, got 2
select datetime, dateadd(minute, -300, body:message_body:order:complete_datetime) FROM
โstage_tableโ. its failing with below error message
Timestamp โโ is not recognized
Any quick help is hugely appreciated.
Thanks
Aravind N
โ02-03-2021 08:52 AM
I suggest not trying to do this in SQL. Just get the datetime as a string, and use a Mapper expression to do the date manipulation using the SnapLogic expression language.