Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Dates comparison using JavaScript

SmithJohn45Nov 12 2024 — edited Nov 12 2024

Apex 23.1

please help to Comparing Dates using JavaScript. I have below DA which works fine after on 2nd or 3rd attemp, what's wrong here with it? if I select a Date from previous Month which DD is less or equals to From Date it is showing alert but from previous Month am select Date which DD is greater than From DD it is not showing alert…
please help what I am doing wrong here? what is the best and recommended way to done this?

note: i used alert and apex.message.showErrors both due to its required. mentioned DD above is DD in MON/DD/YYYY

const date1 = new Date(apex.item("P549_FROM_DATE").getValue());
const date2 = new Date(apex.item("P549_TO_DATE").getValue());
if (date2.getTime() < date1.getTime()) {
     alert('End Date must be greater or equal to Start Date');
     apex.message.showErrors([
     {
         type:       "error",
         location:   ["inline" ],
         pageItem:   "P549_TO_DATE",
         message:    "End Date must be greater or equal to Start Date"
     }
 ]);
}

regards

This post has been answered by Karel Ekema on Nov 12 2024
Jump to Answer

Comments

Processing

Post Details

Added on Nov 12 2024
10 comments
260 views