title: Absence changes in XSL doesn't run properly
body: <p>Got the following error:</p>
  
  <blockquote>
    <p>Arithmetic operator is not defined for arguments of types
    (xs:dateTime, xs:string)</p>
  </blockquote>
  
  <p>Can anyone help me with this?  I am trying to do absence changes.</p>
  
  <pre><code>&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
          xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:this="urn:this"
          xmlns:is="java:com.workday.esb.intsys.xpath.ParsedIntegrationSystemFunctions"
          xmlns:tv="java:com.workday.esb.intsys.TypedValue" xmlns:wd="urn:com.workday/bsvc"
          xmlns:bsvc="urn:com.workday/bsvc" exclude-result-prefixes="xs is tv wd bsvc"
          version="2.0"&gt;
  
          &lt;xsl:variable name="linefeed" select="'&amp;#xA;'" /&gt;
  
          &lt;xsl:output method="text" /&gt;
  
          &lt;xsl:template match="/"&gt;
              &lt;xsl:variable name="StdHoursMultiplier" select="26" /&gt;
  
              &lt;xsl:if
                  test="wd:Payee/wd:Payee_Status_Data/wd:Terminated = '0' and not(wd:Payee/wd:Payee_Status_Data/wd:Leave_Status_Data/wd:On_Leave = '1') and not(exists(wd:Payee/wd:Payee_Reference/wd:ID[@wd:type = 'Contingent_Worker_ID']))"&gt;
  
                  &lt;xsl:if
                      test="wd:Payee/wd:Payee_Job_Data/wd:Payee_Employment_Data/wd:Position_Data/wd:Job_Exempt != '0'"&gt;
  
                      &lt;xsl:value-of select="this:right-padding(5,' ','TW')" /&gt;
  
                      &lt;!-- employee id --&gt;
                      &lt;xsl:value-of
                          select="this:right-padding(11,' ',substring(wd:Payee/wd:Payee_Reference/wd:ID[@wd:type='Employee_ID']/text(),3,6))" /&gt;
  
                      &lt;!-- earning code --&gt;
                      &lt;xsl:value-of select="this:right-padding(6,' ','RGL')" /&gt;
  
                      &lt;!-- amount type --&gt;
                      &lt;xsl:value-of select="this:right-padding(4,' ','H')" /&gt;
  
                      &lt;!-- text --&gt;
                      &lt;xsl:value-of select="this:right-padding(7,' ','1')" /&gt;
  
                      &lt;!-- amount --&gt;
                      &lt;xsl:value-of
                          select="this:left-padding(8,' ',format-number((number(wd:Payee/wd:Payee_Job_Data/wd:Payee_Employment_Data/wd:Position_Data/wd:Scheduled_Weekly_Hours)*52) div $StdHoursMultiplier,'####.00') )" /&gt;
  
                      &lt;!-- line feed --&gt;
                      &lt;xsl:value-of select="$linefeed" /&gt;
  
                  &lt;/xsl:if&gt;
              &lt;/xsl:if&gt;
              &lt;xsl:for-each
                  select="//wd:Payee_Earnings_and_Deductions_Summary_Data/wd:Payee_One_Time_Payments_Summary_Data/wd:Payee_One_Time_Payment_Summary_Data/wd:Payee_One_Time_Payment_Data"&gt;
  
                  &lt;xsl:value-of select="this:right-padding(5,' ','SP')" /&gt;
  
                  &lt;!-- employee id --&gt;
                  &lt;xsl:value-of
                      select="this:right-padding(11,' ',substring(/wd:Payee/wd:Payee_Reference/wd:ID[@wd:type='Employee_ID']/text(),3,6))" /&gt;
  
                  &lt;!-- earning code --&gt;
                  &lt;xsl:value-of select="this:right-padding(6,' ',../wd:External_Payroll_Code)" /&gt;
  
                  &lt;!-- amount type --&gt;
                  &lt;xsl:value-of select="this:right-padding(4,' ','D')" /&gt;
  
                  &lt;!-- text --&gt;
                  &lt;xsl:value-of select="this:right-padding(7,' ','1')" /&gt;
  
                  &lt;!-- amount --&gt;
                  &lt;xsl:value-of
                      select="this:left-padding(10,' ',format-number(sum(wd:Amount/wd:Value),'####.00'))" /&gt;
  
                  &lt;!-- line feed --&gt;
                  &lt;xsl:value-of select="$linefeed" /&gt;
              &lt;/xsl:for-each&gt;
  
              &lt;xsl:if
                  test="wd:Payee/wd:Payee_Status_Data/wd:Terminated = '0' and (wd:Payee/wd:Payee_Status_Data/wd:Leave_Status_Data/wd:On_Leave = '1') and not(exists(wd:Payee/wd:Payee_Reference/wd:ID[@wd:type = 'Contingent_Worker_ID']))"&gt;
  
                  &lt;xsl:if
                      test="wd:Payee/wd:Payee_Job_Data/wd:Payee_Employment_Data/wd:Position_Data/wd:Job_Exempt != '0'"
                      exclude-result-prefixes="#all"&gt;
                      &lt;xsl:choose&gt;
                          &lt;xsl:when
                              test="wd:Payee//wd:Payee_Status_Data/wd:Leave_Status_Data/wd:Paid_Time_off_Accrual_Effect = '1'"&gt;
                              &lt;xsl:value-of select="this:right-padding(5,' ','TW')" /&gt;
  
                              &lt;!-- employee id --&gt;
                              &lt;xsl:value-of
                                  select="this:right-padding(11,' ',substring(wd:Payee/wd:Payee_Reference/wd:ID[@wd:type='Employee_ID']/text(),3,6))" /&gt;
  
                              &lt;!-- earning code --&gt;
                              &lt;xsl:value-of select="this:right-padding(6,' ','RGL')" /&gt;
  
                              &lt;!-- amount type --&gt;
                              &lt;xsl:value-of select="this:right-padding(4,' ','H')" /&gt;
  
                              &lt;!-- text --&gt;
                              &lt;xsl:value-of select="this:right-padding(7,' ','1')" /&gt;
  
                              &lt;!-- amount --&gt;
                              &lt;xsl:variable name="LeaveHours"
                                  select="xs:dateTime(wd:Payee/wd:Payee_Status_data/wd:leave_Status_Data/wd:Estimated_Leave_End_Date) - xs:dateTime(wd:Payee/wd:Payee_Status_data/wd:leave_Status_Data/wd:Leave_Start_Date)cast as xs:string" /&gt;
  
                              &lt;!-- amount --&gt;
  
  
                              &lt;xsl:value-of
                                  select="this:left-padding(8,' ', '80')" /&gt;
  
                              &lt;!-- line feed --&gt;
                              &lt;xsl:value-of select="$linefeed" /&gt;
                              &lt;xsl:value-of select="this:right-padding(5,' ','TW')" /&gt;
  
                              &lt;!-- employee id --&gt;
                              &lt;xsl:value-of
                                  select="this:right-padding(11,' ',substring(wd:Payee/wd:Payee_Reference/wd:ID[@wd:type='Employee_ID']/text(),3,6))" /&gt;
  
                              &lt;!-- earning code --&gt;
  
  
                              &lt;xsl:value-of select="this:right-padding(6,' ','SDP')" /&gt;
  
  
                              &lt;!-- amount type --&gt;
                              &lt;xsl:value-of select="this:right-padding(4,' ','H')" /&gt;
  
                              &lt;!-- text --&gt;
                              &lt;xsl:value-of select="this:right-padding(7,' ','1')" /&gt;
                              &lt;!-- amount --&gt;
  
  
                              &lt;!-- amount --&gt;
                              &lt;xsl:value-of
                                  select="this:left-padding(8,' ',format-number(number(substring-before(substring-after($LeaveHours,'P'),'D')),'####.00'))" /&gt;
  
                          &lt;/xsl:when&gt;
                          &lt;xsl:when
                              test="not(wd:Payee//wd:Payee_Status_Data/wd:Leave_Status_Data/wd:Paid_Time_off_Accrual_Effect = '1')"&gt;
                              &lt;xsl:value-of select="this:right-padding(5,' ','TW')" /&gt;
  
                              &lt;!-- employee id --&gt;
                              &lt;xsl:value-of
                                  select="this:right-padding(11,' ',substring(wd:Payee/wd:Payee_Reference/wd:ID[@wd:type='Employee_ID']/text(),3,6))" /&gt;
  
                              &lt;!-- earning code --&gt;
                              &lt;xsl:value-of select="this:right-padding(6,' ','RGL')" /&gt;
  
                              &lt;!-- amount type --&gt;
                              &lt;xsl:value-of select="this:right-padding(4,' ','H')" /&gt;
  
                              &lt;!-- text --&gt;
                              &lt;xsl:value-of select="this:right-padding(7,' ','1')" /&gt;
  
                              &lt;!-- amount --&gt;
  
                              &lt;!-- amount --&gt;
                              &lt;!-- amount --&gt;
                              &lt;xsl:variable name="LeaveHours"
                                  select="xs:dateTime(wd:Payee/wd:Payee_Status_data/wd:leave_Status_Data/wd:Estimated_Leave_End_Date) - xs:dateTime(wd:Payee/wd:Payee_Status_data/wd:leave_Status_Data/wd:Leave_Start_Date) cast as xs:string" /&gt;
  
  
                              &lt;xsl:value-of
                                  select="this:left-padding(8,' ',format-number(number(substring-before(substring-after($LeaveHours,'P'),'D')),'####.00' ))" /&gt;
  
  
                              &lt;!-- line feed --&gt;
                              &lt;xsl:value-of select="$linefeed" /&gt;
                              &lt;xsl:value-of select="this:right-padding(5,' ','TW')" /&gt;
  
                              &lt;!-- employee id --&gt;
                              &lt;xsl:value-of
                                  select="this:right-padding(11,' ',substring(wd:Payee/wd:Payee_Reference/wd:ID[@wd:type='Employee_ID']/text(),3,6))" /&gt;
  
                              &lt;!-- earning code --&gt;
  
  
                              &lt;xsl:value-of select="this:right-padding(6,' ','SDP')" /&gt;
  
  
                              &lt;!-- amount type --&gt;
                              &lt;xsl:value-of select="this:right-padding(4,' ','H')" /&gt;
  
                              &lt;!-- text --&gt;
                              &lt;xsl:value-of select="this:right-padding(7,' ','1')" /&gt;
                              &lt;!-- amount --&gt;
                              &lt;!-- amount --&gt;
  
                              &lt;xsl:value-of select="this:left-padding(8,' ','0')" /&gt;
  
                          &lt;/xsl:when&gt;
                          &lt;xsl:otherwise&gt;
                              &lt;xsl:value-of select="this:right-padding(5,' ','TW')" /&gt;
  
                              &lt;!-- employee id --&gt;
                              &lt;xsl:value-of
                                  select="this:right-padding(11,' ',substring(wd:Payee/wd:Payee_Reference/wd:ID[@wd:type='Employee_ID']/text(),3,6))" /&gt;
  
                              &lt;!-- earning code --&gt;
                              &lt;xsl:value-of select="this:right-padding(6,' ','SDP')" /&gt;
  
                              &lt;!-- amount type --&gt;
                              &lt;xsl:value-of select="this:right-padding(4,' ','H')" /&gt;
  
                              &lt;!-- text --&gt;
                              &lt;xsl:value-of select="this:right-padding(7,' ','1')" /&gt;
  
                              &lt;!-- amount --&gt;
                              &lt;xsl:value-of
                                  select="this:left-padding(8,' ',format-number((number(wd:Payee/wd:Payee_Job_Data/wd:Payee_Employment_Data/wd:Position_Data/wd:Scheduled_Weekly_Hours)*52) div $StdHoursMultiplier,'####.00') )" /&gt;
  
                          &lt;/xsl:otherwise&gt;
  
                      &lt;/xsl:choose&gt;
  
  
                  &lt;/xsl:if&gt;
                  &lt;!-- line feed --&gt;
                  &lt;xsl:value-of select="$linefeed" /&gt;
              &lt;/xsl:if&gt;
  
          &lt;/xsl:template&gt;
  
          &lt;xsl:function name="this:right-padding"&gt;
              &lt;xsl:param name="length" as="xs:integer" /&gt;
              &lt;xsl:param name="padChar" as="xs:string" /&gt;
              &lt;xsl:param name="stringToPad" /&gt;
  
              &lt;xsl:sequence
                  select="substring(string-join(($stringToPad, for $i in (1 to $length) return $padChar),''),1,$length)" /&gt;
  
          &lt;/xsl:function&gt;
  
  
          &lt;xsl:function name="this:left-padding" as="xs:string"&gt;
              &lt;xsl:param name="length" as="xs:integer" /&gt;
              &lt;xsl:param name="padChar" as="xs:string" /&gt;
              &lt;xsl:param name="stringToPad" /&gt;
              &lt;xsl:choose&gt;
                  &lt;xsl:when test="string-length($stringToPad) &amp;gt; $length"&gt;
                      &lt;xsl:sequence
                          select="substring($stringToPad, string-length($stringToPad) - $length + 1, $length)" /&gt;
                  &lt;/xsl:when&gt;
                  &lt;xsl:otherwise&gt;
                      &lt;xsl:sequence
                          select="substring(string-join((for $i in (1 to $length - string-length($stringToPad)) return $padChar, $stringToPad),''),1,$length)" /&gt;
                  &lt;/xsl:otherwise&gt;
              &lt;/xsl:choose&gt;
          &lt;/xsl:function&gt;
      &lt;/xsl:stylesheet&gt;
  </code></pre>