Hi
Need to validate the date on input widget should be 18 years ago before current date
any idea how to do it on if condition?
Thank you so much
Hello mark
You can use AddYears and pass CurrDate() and -18 as the input parameters. It will return a date that is 18 years before the current date.
the comparison would be
MyDateTime <= AddYears(CurrDate(), -18)
https://success.outsystems.com/Documentation/10/Reference/Logic/Built-in_Functions/Date_and_Time_Built-in_Functions#AddYears
AddYears returns a DateTime. If you will compare against a date, need to convert to date using DateTimeToDate.
Cheers
EDIT. I was slow, lol ;)
you can check in an if:
date < AddYears(CurrDate(), -18)
Hi Mark,
The easiest way to do input validation is using the native features for that.
Please check the documentaion on https://success.outsystems.com/Documentation/10/Developing_an_Application/Design_UI/Forms/Validate_Form_Inputs
and this lesson https://www.outsystems.com/learn/lesson/857/input-validation/
In your case you will combine the examples in this material with BuiltIn Function DiffDays(Date1,Date2) that returns the number of the days between 2 dates.
Best regards
Fabio Fantato
Hi Martin
Thank you so much for your response but its not working
I try these two:
SyntaxEditor Code Snippet
CurrDate(EmployeeStructureForm.Record.Birthdate) < AddYears(CurrDate(), -18)
EmployeeStructureForm.Record.Birthdate < AddYears(CurrDate(), -18)
Mark Anthony Gonzales wrote:
EmployeeStructureForm.Record.Birthdate < DateTimeToDate(AddYears(CurrDate(), -18))
If Birthdate is a DATE, need to convert the result of AddYears to Date.
Eduardo Jauch wrote:
Hi Eduardo,
Thank you so much, its now working
Mark
I want to display DD-MM-YYY instead of 01-01-1900 if date is null.
Please suggest
Sandeep Khare wrote:
In this case, your database won't record the value "YYYY-MM-DD", so you must format the expression on the screen to show "YYYY-MM-DD" when the date is null. Try the following expression:
If (YourEntity.Atributte.Date) = NullDate(), "YYYY-MM-DD" , YourEntity.Atributte.Date)
You can try (Currdate -18 = true OR Currdate <>18 = false)