Applies To:
CPQ
Summary:
This article will show you how to write a CPQ tag that will compare two dates within CPQ.
Details:
Currently, CPQ does not have tag operator to compare two dates. Using operator tags such as [GT] (Greater Than) or [LT] (Less Than) will only compare number and string values; therefore, will not work for dates.
Solution/Workaround:
The best optimal way to compare two dates in CPQ is to use a VBScript function, DateDiff, in a CPQ Eval Tag.
Correct tag to use is below:
<*Eval(DateDiff("interval","Date1","Date2"))*>
Return results of tag would be:
Positive Number = Number of day(s) from "Date1" to "Date2".
![](/sap/support/sapnotes/public/services/embedded_image.htm?iv_guid=00109B36D5CA1EDD8585920BF369A904&iv_key=002075125900001222432022)
Negative Number= Number of day(s) after "Date1" to "Date2".
![](/sap/support/sapnotes/public/services/embedded_image.htm?iv_guid=00109B36D5CA1EDD8585920BF3698904&iv_key=002075125900001222432022)
0 = Same dates are being compared.
![](/sap/support/sapnotes/public/services/embedded_image.htm?iv_guid=00109B36D5CA1EDD8585920BF3696904&iv_key=002075125900001222432022)
Sample of what tag should look like:
E.g <*Eval(DateDiff("d","05/04/2014","04/04/2015"))*>
Comments:
- The 'DateDiff' is Visual Basic Function. Click here to find more information about this function.
- VB Function must be used inside of a CPQ Eval (<* Eval(...) *>) tag.