Hi,
I want to filter the data in a table. The data should fall in the last 26 weeks excluding the current week.
The first day of the week is Sunday and last day of the week is Saturday.
My filtered data should fall in the last 26 weeks excluding the current week.
Any Ideas?
Use code below to find start and end dates and use them to filter your data
Date dateFrom;
Date dateTo;
;
dateTo = dateStartWk(systemDateGet());
dateFrom = dateTo - 26 * 7;
info(strFmt("%1-%2", dateFrom, dateTo));
How to filter records in a form by code
Thanks for the reply.
I got this part of the solution.
My issue is how to get the date of last Saturday as the week ends on Saturday (4 4 5 calendar)
Date dateFrom;
Date dateTo;
;
dateTo = date of last Saturday <<<<<<<<<< How to get this value ( any funtions or methods?), As of today that will be
1/21
dateFrom = dateTo - 26 * 7;
info(strFmt("%1-%2", dateFrom, dateTo));
Function dateStartWk returns first day of week. If you want to find the last day of previous week you can modify code as following
dateTo = dateStartWk(systemDateGet()) - 1;
Thanks for the tip.
When we consider the system date the first date is Monday … here is the Solution
static void Example_date(Args _args)
{
Date dateFrom;
Date dateTo;
date fd;
;
fd = dateStartWk(systemDateGet());
dateTo = fd - 2;
dateFrom = dateTo - ((5 * 7) -1); // shud be 3*7 - 1 as ToDate value is also Included
info(strFmt("%1-%2-%3", fd, dateTo, dateFrom));
}