Hi Everyone,
In this article we will see how we can Calculate Date by adding and subtracting No. of Days / Months based on CalcDate and DateFormula datatype.
Here, I define three variables required for:
(1) "No of Days" - To define No. of Days / Months as required.
You can also use these units denoted as:
<Unit> = D | WD | W | M | Q | Y (D=day, WD=weekday, W=week, M=month, Q=quarter, Y=year).
(2) "From Date" and "To Date" Date type Variables to store calculated date in it.
page 50103 "Date from Date Formula"
{
PageType = Card;
ApplicationArea = All;
UsageCategory = Administration;
SourceTable = Integer;
layout
{
area(Content)
{
group(General)
{
field("No. of Days"; "No. of Days")
{
ApplicationArea = All;
}
}
}
}
actions
{
area(Processing)
{
action("Calculate Date")
{
ApplicationArea = All;
Promoted = True;
PromotedIsBig = true;
Image = Calculate;
PromotedCategory = Process;
trigger OnAction()
begin
FromDate := CALCDATE('-' + FORMAT("No. of Days"), TODAY);
ToDate := CALCDATE(FORMAT("No. of Days"), TODAY);
Message('From Date = %1 and To Date = %2', format(FromDate),
Format(ToDate));
end;
}
}
}
var
"No. of Days": DateFormula;
FromDate: Date;
ToDate: Date;
}
I have created a card page here and action button to calculate Date based on the value
of "No. of Days". And Here is the Page Design:
Comments
Post a Comment