Script: if date equals today

I have an xml with invoice date: Is it possible in a script to select only invoices dated today ?

2024-03-06T14:45:00Z

To be honest, I’m not a XSLT expect but I assume that this can be accomplished by the following steps:

  1. Add a new Workflow process to your Workflow Configuration
  2. Add the Local Variable currentDate to the Workflow process
  3. Insert the Set Job Infos and Variables Workflow plugin and apply the following to this Workflow plugin:
    • Var/Info#: currentDate
    • Value: %y-%m-%d
  4. Insert the Open XSLT Workflow plugin and apply the following to this Workflow plugin:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" indent="yes"/>
	
	<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="/records">
		<xsl:copy>
			<xsl:apply-templates select="record[date[starts-with(text(), '%{currentDate}')]]"/>
		</xsl:copy>
	</xsl:template>
</xsl:stylesheet>

In performing the above steps, I have assumed that the XML file contains the following content:

<?xml version="1.0" encoding="UTF-8"?>
<records>
	<record>
		<date>2024-03-06T14:45:00Z</date>
		<name>Jane Doe</name>
	</record>
	<record>
		<date>2024-04-05T16:16:00Z</date>
		<name>John Doe</name>
	</record>
</records>

Result:

<?xml version="1.0" encoding="UTF-8"?>
<records>
	<record>
		<date>2024-04-05T16:15:00Z</date>
		<name>John Doe</name>
	</record>
</records>

I managed this using a Condition and Action step in DataMapper.

date.xml (820 Bytes) today.OL-template (7.2 KB) today.pdf (3.0 KB) todays date.OL-datamapper (4.2 KB)

The condition:

thks Marten, I will try this

1 Like

Thks Erik. I will try