Liquid XML Studio
Now
See Also Send Feedback
Data Mapping > Data Mapper Functions > By Category > Date Time > Now

Glossary Item Box

Function Name
Now
Category
DateTime
Icon
Now
Description
Return the current DateTime
Inputs
None -
Outputs
Result DateTime when mapping occurs
Properties
None -

Usage

The Data Mapper DateTime Now function returns the current DateTime 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 Now function, you provide a log of the time at which the mapping process was executed, which your target application can then refer to. To apply the DateTime Now 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-22T08:20:45.57</transferred>
 </client>
 <client>
  <is_business>true</is_business>
  <contact_name>Jack Taylor</contact_name>
  <transferred>2009-10-15T10:38:23.11</transferred>
 </client>
</current_customers>

The data models client records, with the target including an indicator of a DateTime, which will be the date and time the source data is mapped. Here is the Data Mapper with Source and Target imported:

Data Mapper Source and Target

Drag the DateTime Now function from the Component Palette into the mapping area:

Now Component

Now Transform Added

The Now function has no inputs and one output, the current DateTime. 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 Now value as input to some other function.

Connect the Now function output to the "transferred" input in the XML Writer.

Now Mapped

Now, when mapping occurs, the Mapper will write the current DateTime to a "transferred" element within each "client" parent element in the output.

Finally, connect the remaining inputs and outputs:

Input and Output Connections Mapped

We can now execute the transform by pressing Shift-F5 or the Execute button (Execute). 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-03T09:13:52.296875Z</transferred>
 </client>
 <client>
  <is_business>true</is_business>
  <contact_name>Steve Jackson</contact_name>
  <transferred>2012-05-03T09:13:52.296875Z</transferred>
 </client>
</current_customers>

The output contains the DateTime for when the data was mapped.

The Now function outputs the full DateTime value, including the day, month, year and time (including hour, minute, second and millisecond). If you only need to record the day on which mapping occurred, you can opt for the Today function as an alternative.

See Also