Function Name |
Today | ||
Category |
DateTime | ||
Icon |
![]() |
||
Description |
Return the DateTime for the current date | ||
Inputs |
|
||
Outputs |
|
||
Properties |
|
The Data Mapper DateTime Today function returns the current date value. When mapping data from one application to another, developers often record information related to the mapping activity itself as well as the data. For example, you may wish to use the mapping time as a record of the last time the data was considered valid within the application context. By using the Today function, you provide a log of the date on which the mapping process was executed, which your target application can then refer to. To apply the DateTime Today function, use the following process:
Create a new Data Mapper file, dragging your XML data source and targets into the editor area. For this example we are using client_source.xsd, an XML Schema Definition inferred from the following source:
Source XML |
Copy Code
|
---|---|
<clients> <customer business="false"> <name>Mary Smith</name> </customer> <customer business="true"> <name>Steve Jackson</name> </customer> </clients> |
For our target schema we will be using client_alt_target.xsd, inferred from the following XML:
Target XML |
Copy Code
|
---|---|
<current_customers> <client> <is_business>false</is_business> <contact_name>Jim Brown</contact_name> <transferred>2004-03-22</transferred> </client> <client> <is_business>true</is_business> <contact_name>Jack Taylor</contact_name> <transferred>2009-10-15</transferred> </client> </current_customers> |
The data models client records, with the target including an indicator of a DateTime, which in this case will be the date on which the source data is mapped. Here is the Data Mapper with Source and Target imported:
Drag the DateTime Today function from the Component Palette into the mapping area:
The Today function has no inputs and one output, the current date value in DateTime format. The output should be connected to the target item, whether an item in the XML Writer or another component in the Mapper, for example if you plan on using the Today value as input to some other function.
Connect the Today function output to the "transferred" input in the XML Writer.
Now, when mapping occurs, the Mapper will write the current DateTime date to a "transferred" element within each "client" parent element in the output.
Finally, connect the remaining inputs and outputs between Reader and Writer:
We can now execute the transform by pressing Shift-F5 or the Execute button (). The transform is applied and the file we selected as output opens in the editor:
Output XML |
Copy Code
|
---|---|
<current_customers> <client> <is_business>false</is_business> <contact_name>Mary Smith</contact_name> <transferred>2012-05-02T23:00:00Z</transferred> </client> <client> <is_business>true</is_business> <contact_name>Steve Jackson</contact_name> <transferred>2012-05-02T23:00:00Z</transferred> </client> </current_customers> |
The output contains the DateTime for when the day the data was mapped. The time portion is provided although its content is only a placeholder - this allows your target processing to alter the time portion if you require.