Working with DateTime
Datetime is one of the most complex primitive data type which one needs to understand while working with the transformation in APPSeCONNECT. This article will help you understand how we can make use of Datetime field efficiently and effectively such that all the destination data is compatible.
Steps to define date time field
A DateTime is an inherent property of a particular attribute of a schema. The attribute can be source attribute or a target attribute. By source schema we mean the schematic definition of the data that an application interact with. APPSeCONNECT supports different primitive data types in addition to DateTime. To define DateTime field in a schema, we need to first create an attribute on that particular schema. To do such a thing, please follow the steps mentioned below :
- Open portal.appseconnect.com
- Go to App Section and click on Schema of a particular Application.
- You can add a new Schema from there, which will allow you to define a schema for a particular endpoint
- You can add as many fields as you want, each attribute will have its type. (DateTime for instance).
Also Check out: Integrating Business Applications – 5 Key Points to Consider
Once the date is mentioned on a particular schema, you can use it to store date time during transformation. You can read the documentation to know more on how to add or import schema in APPSeCONNECT.
The transformation allows you to pick a particular field, do execute a logic that you define per field, and then create a separate document. The transformation lets you define the fields that you want to expose to the target document, such that you can push the document easily. Now while defining transformation, you might need some tooling which you want to execute on a datetime field to get proper results. Let us discuss how to do such a thing using APPSeCONNECT transformation engine.
Some common methods to transform Datetime field:
|Get date or a default date||[genericlib:GetDataOrDefault(data,defaultText)]||The idea is to generate a default data if there is no data present for a particular mapping|
|Format date or a default date||[genericlib:GetDateFormattedOutput(data,formatspecifier,defaultDate)]||This mapping will reformat the data using a format specifier or else will return a dummy date specified as third parameter.|
|Get reformatted Local or UTC datetime||[genericlib:GetLocalTime(format)] / [genericlib:GetUniversalDateTime(format)]||This mapping will just get the current datetime or current Universal datetime and reformat the data using a format specifier.|
|Gets a local or UTC datetime||[genericlib:GetUtcTime()] / [genericlib:GetLocalDateTime()]||This mapping will just get the current datetime or current Universal datetime|
|Adds a number of days to a date||[genericlib:DateAdd(datestring,no_of_days)]||Add a number of days mentioned in parameter to a specific date and returns the output.|
|Reformat a date||[genericlib:FormatDate(date,format)]||Just takes a date and reformat it to a valid format.|
|Generate a datetime||[genericlib:DateFromParts(year,month,day)][genericlib:TimeFromParts(hour,minute,seconds,fractions,precision)]||Both DateFromParts and TimeFromParts allows to generate date time, by specifying the date and part elements in parameter.|
|Check for Date||[genericlib:IsDate(date)]||Identifies whether the date passed as parameter is a valid date or not.|
|Days elapsed between two dates||[genericlib:DateDifference(date1,date2,format, range)]||Returns the number of days or month or year elapsed between two date. Value of range could be “month”, “year”, “day”.|
Note : It is worth noting, the transformation engine always parses the datetime field into its own format, so if you do not specify the format of an output, the transformation engine will generate the format and return result.