Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
2 replies
Subscribers
7 subscribers
Views
3351 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Cdt Casting is converting the date time to system timezone
akhilaa
over 7 years ago
Json response is giving date time value as output. We are casting this output to a cdt field (date time field).
We are using a!fromJson to convert the json response and map it to cdt.
The issue is casting is converting date time value to system time zone which is EST.
Example:
Json response is:"LAST_MODIFIED_DATETIME":"1\\/13\\/2017 2:52:00 AM"
a!fromJson("LAST_MODIFIED_DATETIME":"1\\/13\\/2017 2:52:00 AM").LAST_MODIFIED_DATETIME gives
1/13/2017 2:52:00 AM
After casting to cdt the value is :LAST_MODIFIED_DATETIME=1/12/2017 9:52 PM EST
Is there a way we can get the original json output as cdt output?
Why is the cdt altering the value and is there a way to stop the conversion .
OriginalPostID-257592
Discussion posts and replies are publicly visible
0
aloks0189
Certified Lead Developer
over 7 years ago
@akhilaa this is the known behavior, when you convert the data in JSON using tojson() function and again use fromjson() then the format of the date gets change, i too have face the same issue earlier, so i have shared a component named as 'Date Formatter in JSON' please click on this link:
forum.appian.com/.../summary
in order to work with this, you need follow this sample:-
==================================================
load(
local!modiedData: modifyjsondata("dob", a!toJson(ri!empDetails), "yyyy-mm-dd", "mm/dd/yyyy"),
local!response: modifyjsondata("joinDate", local!modiedData, "yyyy-mm-dd", "mm/dd/yyyy"),
local!response
)
==================================================
Here let's assume that,
=> local!modiedData is holding the data retrieved in form of JSON whose date is got affected,
=> local!response is holding the required data which can be of type CDT, or can be cast to CDT, or can be store into Rule input of type CDT
This function has following parameters:-
1. which property of json is getting affected of type Date, in your case, it might be LAST_MODIFIED_DATETIME i guess
2. provide the complete json data which contains LAST_MODIFIED_DATETIME also within it along with other properties
3. existing Date format of date in the JSON data
4. Expected Date Format to be returned
by passing these parameters correctly you will be able to get the a formatted JSON as you are expecting it to be, which you can use to store into CDT
hope this will help you
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
aloks0189
Certified Lead Developer
over 7 years ago
Also for more reference, you can go through the reference which is been shared along with this Shared Component
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel