I'm trying to compare two dates with time. I'm able to compare just the date, but when I add the time element it doesn't work. I'm not sure what the correct format should be.

<xsl:if test="ddwrt:FormatDateTime(ddwrt:TodayIso(),1033,'yyyyMMdd hhmmss') &lt; ddwrt:FormatDateTime(string(@Date_x002f_Time), 1033, 'yyyyMMdd hhmmss')">

My goal is to compare the two dates to check if there is less than 30 minutes to the Date_x002f_Time field. If it is 3:30pm today and @Date_x002f_Time value is 3:35pm then my value will not show. If it is 3:00pm today and Date_x002f_Time value is 3:35pm then my value will show

1 Answer 1


Try to define two variables for data1 and date2 as the following

<xsl:variable name="date1" select="ddwrt:FormatDateTimeUsingCurrentContext(string(@First-date))"/>

<xsl:variable name="date2" select="ddwrt:FormatDateTimeUsingCurrentContext(string(@Second-date))"/>

then compare as the following

<xsl:if test="$date1 &lt;= $date2">

  • check the condition &lt;= and firld name in variable defination Nov 2, 2016 at 17:03
  • I changed to gt and lt and made sure I was using the correct datetime fields. But still no results.
    – LAL1982
    Nov 2, 2016 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.