Expand my Community achievements bar.

SOLVED

How to get the day of the month from date field

Avatar

Level 1

Hello - I have a date/time field (DateEffective) that the user will fill out, and I need to determine if the day of the month is before the 15th or from the 15th on. For now, I created another calculated field (Cutoff) to try to get the date value using the getDate method, but it doesn't seem to work. What am I doing wrong?

if (DateEffective.rawValue == null || DateEffective.rawValue.length == 0)
{
Cutoff.rawValue = "waiting";
}
else {

Cutoff.rawValue = DateEffective.getDate();

}

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

The DateEffective is an XFA Object, so doesn't have a getDate() method, and the rawValue of a DateField returns a string, so you will need to turn that into a date object before calling getDate() on it.

Try;

util.scand('yyyy-mm-dd',DateEffective.rawValue).getDate()

Regards

Bruce

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

The DateEffective is an XFA Object, so doesn't have a getDate() method, and the rawValue of a DateField returns a string, so you will need to turn that into a date object before calling getDate() on it.

Try;

util.scand('yyyy-mm-dd',DateEffective.rawValue).getDate()

Regards

Bruce

Avatar

Level 1

Thank you so much, that worked perfectly!