1. How to get current date in dynamics 365 Finance and Operations?
In Dynamics 365 Finance and Operations a date function today() is used to get the current date from the given date in dynamics 365 finance and operations,This function returns the current date that is used by the client.
Here i have created one runnable class DateFunctionsJob. Once you created the class , you can copy and paste the below codes as per your requirements.
internal final class DateFunctionsJob
{
public static void main(Args _args)
{
Transdate dateToday ;
dateToday = today();
info(strfmt("Date- %1",dateToday));
}
}
Output :
Date - 7/22/2023
2. How to gets the Month Number from the given date in Dynamics 365 Finance and Operations?
public static void main(Args _args)
{
Transdate dateToday;
int monthNumber;
dateToday = today();
monthNumber=mthofYr(dateToday);
info(strfmt("Month Number - %1",monthNumber));
}
Output :
Month Number- 7
3. How to gets the Month Name from the given date in Dynamics 365 Finance and Operations?
public static void main(Args _args)
{
Transdate dateToday;
str monthName ;
dateToday = today();
monthName = mthname(mthofYr(dateToday));
info(strfmt("Month Name - %1",monthName));
}
Output :
Month Name - July
4. How to gets the Day Number from the given date in Dynamics 365 Finance and Operations?
public static void main(Args _args)
{
Transdate dateToday;
int dayNumber;
dateToday = today();
dayNumber = dayOfMth(dateToday);
info(strfmt("Day Number- %1",dayNumber));
}
Output :
Day Number - 22
5. How to gets the Day Name from the given date in Dynamics 365 Finance and Operations?
public static void main(Args _args)
{
Transdate dateToday;
str dayName;
dateToday = today();
DayName = dayname(dayOfMth(dateToday));
info(strfmt("Day Name - %1",dayName));
}
Output :
Day Name - Saturday
6. How to get the year from the given date in Dynamics 365 Finance and Operations?
public static void main(Args _args)
{
Transdate dateToday;
int year ;
dateToday = today();
Year =year(dateToday);
info(strfmt("Year - %1",year));
}
Output :
Year - 2023
7. How to gets the week day number from the given date in Dynamics 365 Finance and Operations?
public static void main(Args _args)
{
Transdate dateToday;
int weekDayNumber;
dateToday = today();
weekDayNumber= dayOfwk(dateToday);
info(strfmt("Week Day Number - %1",weekDayNumber));
}
Output :
Week Day Number - 6
8. How to gets the day of year from the given date in Dynamics 365 Finance and Operations?
public static void main(Args _args)
{
Transdate dateToday;
int dayOfYear;
dateToday = today();
dayOfYear= dayOfyr(dateToday);
info(strfmt("Day of year - %1",dayOfYear));
}
Output :
Day of year - 203
9. How to get week of the year from the given date in Dynamics 365 Finance and Operations?
public static void main(Args _args)
{
Transdate dateToday;
int weekOfYear;
dateToday = today();
weekOfYear= wkofyr(dateToday);
info(strfmt("Week of the year - %1",weekOfYear));
}
Output :
Week of the year - 29