Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

compare date fields in a table

Avatar

Level 3

I have a table with two date fields

Both date fields are in a different subform, but in the same table and row

I want to compare dose fielfds.

Date 2 must be newer than Date 1

The pattern is D-M-YY

This is what i have so far, but is doesn't work

var vDate1 = Date2Num($.rawValue, "YY-M-D")
var vDate2 = Date2Num(DateField2.rawValue, "YY-M-D")

     if (HasValue (vDate2)) then
          if (vDate2 <= vDate1) then
          xfa.host.messageBox("Error message")
          $.rawValue = null
          endif
     endif

Is there someone who can help me with this?

3 Replies

Avatar

Level 4

First print out one of the datefields in order to see the correct format.

For example:

xfa.host.messgeBox(DateField2.rawValue)

Then change the format to the correct one.

Date2Num(DateField2.rawValue, "YOUR-FORMAT")

Avatar

Level 10

You have to use the formattedValue for the date variables.

var vDate1 = Date2Num($.formattedValue, "YY-M-D")
var vDate2 = Date2Num(DateField2.formattedValue, "YY-M-D")

     if (HasValue (vDate2)) then
          if (vDate2 <= vDate1) then
               xfa.host.messageBox("Error message")
               $ = null
          endif
     endif