1

We have Sterling B2B Integrator for our EDI processing. I have a need to add the date to a file name, however, I need to assign yesterday's date and have not found a good option. I'm too new to xslt to figure it out.

It is in xlst 1.0. It looks like we have a date extension - xmlns:date="http://exslt.org/dates-and-times

I have this set up in our style sheet which works to give me the date for when it's run. Any non complex suggestions on how to get this to be yesterday's date?

<xsl:variable name="CUSTOM4">
    <xsl:value-of select="date:format-date(date:date(),'yyyyMMdd')"/>
</xsl:variable>
Carina S
  • 11
  • 2
  • 1
    See if your processor supports http://exslt.org/date/functions/add-duration/index.html. If not, you can use the template provided on the same page, or adapt the answer given here: http://stackoverflow.com/a/27412319/3016153 – michael.hor257k Apr 06 '17 at 15:20
  • This looks like it may work, but again, being too new to xslt, not sure if I need everything listed here? – Carina S Apr 06 '17 at 19:36
  • Not sure if I need all the extra parms like a and I don't know what a floor is. – Carina S Apr 06 '17 at 20:00
  • `floor()` is a basic function in any programming language. As for what is needed for this calculation, see: https://en.wikipedia.org/wiki/Julian_day#Converting_Julian_or_Gregorian_calendar_date_to_Julian_day_number – michael.hor257k Apr 06 '17 at 20:07

2 Answers2

0

I found this link to help your question.I think this is the one what you need to get privious day.

http://www.xsltfunctions.com/xsl/functx_previous-day.html

Good Luck !

Sojimanatsu
  • 619
  • 11
  • 28
0

You might have better luck computing the date using a BP then injecting it as a parameter to the XSLT

Here is a BP fragment:

<operation name="PreviousDay">
  <participant name="TimestampUtilService"/>
  <output message="TimestampUtilServiceArgs">
    <assign to="." from="*"></assign>
    <assign to="action">add</assign>
    <assign to="baseTime">now</assign>
    <assign to="format">yyyyMMdd</assign>
    <assign to="offsetTime">-1</assign>
    <assign to="scale">day</assign>
  </output>
  <input message="inmsg">
    <assign to="." from="*"></assign>
  </input>
</operation>
Stavr00
  • 3,219
  • 1
  • 16
  • 28