Date Time Utilities

Content Type: Module
Categories: Utility

Overview

This module helps to get the Next Month Start and End Date, the Previous Month Start and End date, No. of weeks in a month, Current week in the month, Month of the year, Week of the year, and Working days between dates.

Days:

  • NoOfDaysinMonth

Months:

  • NextMonthStartDate
  • NextMonthEndDate
  • PreviousMonthStartDate
  • PreviousMonthEndDate
  • MonthStartDate
  • MonthEndDate

Weeks:

  • CurrentWeekinMonth
  • NoOfWeeksinMonth
  • TotalWeeksinYear

Working Days:

  • WorkingDaysIncludingDates
  • WorkingDaysExcludingDates

Documentation

Typical usage scenario


Date Time Utilities provides ready-made date calculations that Mendix expressions do not cover out of the box, so you do not have to hand-write the same Java in every app. All calculations run server-side in microflows.


Use it when you need to:


- Build reporting and dashboard filters — resolve "this month", "last month", or "next month" into concrete start and end dates to drive XPath constraints and date range filters.

- Calculate lead times and SLAs in working days — measure business days between two dates while excluding weekends, for order fulfilment, ticket resolution, or approval deadlines. Both inclusive and exclusive counting are supported.

- Default date fields on a form — pre-fill period start and end dates on timesheets, invoices, payroll runs, and expense claims.

- Drive planning and scheduling screens — show the current week of the month, the current week of the year, or how many weeks a given month spans.

- Validate or paginate by month — get the number of days in any month to build calendar grids or bound a day-of-month input.


The module suits any app that works with monthly or weekly periods, and is especially useful in reporting, HR, finance, and field-service applications.


Features and limitations


The module contains 14 Java actions, grouped into four folders. Month is 1-based (1 = January).


Days


- NoOfDaysinMonth — parameters: Year, Month (Integer/Long). Returns Integer/Long: the number of days in that month.


Months


- MonthStartDate — parameters: Year, Month (Integer/Long). Returns Date and time: the first day of that month.

- MonthEndDate — parameters: Year, Month (Integer/Long). Returns Date and time: the last day of that month.

- NextMonthStartDate — no parameters. Returns Date and time: the first day of next month.

- NextMonthEndDate — no parameters. Returns Date and time: the last day of next month.

- PreviousMonthStartDate — no parameters. Returns Date and time: the first day of last month.

- PreviousMonthEndDate — no parameters. Returns Date and time: the last day of last month.

- MonthOfYear — no parameters. Returns Integer/Long: the current month as 1-12.


Weeks


- CurrentWeekinMonth — no parameters. Returns Integer/Long: which week of the current month today falls in.

- NoOfWeeksinMonth — parameter: DateValue (Date and time). Returns Integer/Long: the number of weeks in the month that date belongs to.

- TotalWeeksinYear — parameter: Year (Integer/Long). Returns Integer/Long: the total weeks in that year.

- WeekOfYear — no parameters. Returns Integer/Long: the current week number of the year.


Working Days


- WorkingDaysIncludingDates — parameters: StartDate, EndDate (Date and time). Returns Integer/Long: working days between the two dates, excluding Saturday and Sunday, counting the start and end dates themselves.

- WorkingDaysExcludingDates — parameters: StartDate, EndDate (Date and time). Returns Integer/Long: working days between the two dates, excluding Saturday and Sunday, not counting the start and end dates themselves.


Dependencies


- Mendix Studio Pro 10.24.17 or higher.


No other Marketplace modules, Java libraries, or third-party services are required.


Installation


1. In Studio Pro, open your app and go to Marketplace > Import module package, or download the module package and use App > Import module package.

2. Select Date Time Utilities and import it into your app.

3. The module is added as DateTimeUtilities, with the Java actions organized into the Days, Months, Weeks, and Working Days folders.


After importing, run App > Synchronize app directory and deploy once so the Java actions are compiled.


Configuration


No configuration is required — there are no constants, scheduled events, or settings to change.


To use an action, add a Call Java action activity to a microflow, pick the action from the DateTimeUtilities module, supply any parameters, and store the result in a variable.


If your app uses module security, grant the relevant user roles the module role so the actions can be called.


Known bugs


None.


Frequently Asked Questions


Can I use these actions in a nanoflow?

No. These are Java actions, so they run on the server and can only be called from microflows. Call the microflow from your nanoflow if you need the result client-side.


Which date and time zone do the no-parameter actions use?

They use the server's current date and time zone, not the end user's device. This makes results consistent across users, unlike a client-side implementation.


What is the difference between WorkingDaysIncludingDates and WorkingDaysExcludingDates?

Both count weekdays between two dates and skip Saturdays and Sundays. The "Including" variant counts the start and end dates themselves if they are weekdays; the "Excluding" variant does not.


Do the working-day actions account for public holidays?

No. Only Saturdays and Sundays are excluded. Subtract holidays yourself if your process requires it.


Is Month 0-based like in Java?

No. All actions take and return Month as 1-based, so January is 1 and December is 12.


Does this module add anything to my database?

No. It contains only Java actions — there are no entities and no domain model changes.


How is this different from the Date Time Functions module?

Date Time Functions is the client-side equivalent, built from JavaScript actions for use in nanoflows. Date Time Utilities is Java-based for use in microflows, takes real Date and time parameters instead of formatted strings, and offers both inclusive and exclusive working-day counts.

Releases

Version: 4.1.0
Framework Version: 10.24.17
Release Notes:

**Date Time Utilities**

This module helps to get Next Month's start and end date, Previous Month start and end date, Current week in a month, Month of the year, No. of weeks in a month, week of year and working days between dates.


**What's new in V5.0.0**


1. Converted to Mendix Studio Pro 10.24.17.

2. Fixed **MonthOfYear**, which previously returned the day of the month instead of the month of the year. It now returns 1-12. If you were compensating for the old behaviour, remove that workaround.


**Days**:

**NoOfDaysinMonth:**

Get total number of days in month using year and month value.


**Months**:

**NextMonthStartDate:**

Get the Next month Start date.


**NextMonthEndDate:**

Get the Next month End date.


**PreviousMonthStartDate:**

Get the Previous month Start date.


**PreviousMonthEndDate:**

Get the Previous month End date.


**MonthStartDate:**

Get Month Start date using year and month value.


**MonthEndDate:**

Get Month End date using year and month value.


**MonthOfYear:**

Get the month of the current year (1-12).


**Weeks**:

**CurrentWeekinMonth:**

Get the current week of the month.


**NoOfWeeksinMonth:**

Get total number of weeks in a Month using a date value.


**TotalWeeksinYear:**

Get the total weeks in year using year value.


**WeekOfYear:**

Get the week of the current year.


**Working Days:**

**WorkingDaysIncludingDates:**

Get working days (excluding Saturday and Sunday) using start date and end date (Start and End date will be included in the working days).


**WorkingDaysExcludingDates:**

Get working days (excluding Saturday and Sunday) using start date and end date (Start and End date will not be included in the working days).


**Typical usage scenario:**

Useful in date scenarios of past dates, future dates and in business working days.


**Features and limitations**

1.Useful to get the start and end date of previous and next month.


2.Userful to get the Current week in month, Month of year and week of year.


3.Useful to get the working days including and excluding start and end date.


**Dependencies**

Mendix Studio Pro 10.24.17


**Screenshots:**

![DateTimeUtilities](https://github.com/user-attachments/assets/5779dfe4-e0f9-4795-85aa-fa4b1836126c)

Version: 4.0.0
Framework Version: 9.24.18
Release Notes: **Date Time Utilities** This module helps to get Next Month's start and end date,Previous Month start and end date,Current week in a month, Month of the year,No. of weeks in a month, week of year and working days between dates. **Days**: **NoOfDaysinMonth:** Get total number of days in month using year and month value. **Months**: **NextMonthStartDate:** Get the Next month Start date. **NextMonthEndDate:** Get the Next month End date. **PreviousMonthStartDate:** Get the Previous month Start date. **PreviousMonthEndDate:** Get the Previous month End date. **MonthStartDate:** Get Month Start date using year and month value. **MonthEndDate:** Get Month End date using year and month value. **Weeks**: **CurrentWeekinMonth:** Get the current week of the month. **NoOfWeeksinMonth:** Get total number of weeks in a Month. **TotalWeeksinYear:** Get the total weeks in year using year value. **WeekOfYear:** Get the week of the current year. **Working Days:** **WorkingDaysIncludingDates:** Get working days (excluding Saturday and Sunday) using start date and end date (Start and End date will be included in the working days). **WorkingDaysExcludingDates:** Get working days (excluding Saturday and Sunday) using start date and end date (Start and End date will not be included in the working days). **Typical usage scenario:** Useful in date scenarios of past dates, future dates and in business working days. **Features and limitations** 1.Useful to get the start and end date of previous and next month. 2.Userful to get the Current week in month, Month of year and week of year. 3.Useful to get the working days including and excluding start and end date. **Dependencies** 9.24.18 **Screenshots:** ![DateTimeUtilities](https://github.com/user-attachments/assets/5779dfe4-e0f9-4795-85aa-fa4b1836126c)
Version: 3.0.0
Framework Version: 9.12.4
Release Notes: DateTimeUtilities in 9.12.4 and above
Version: 2.0.0
Framework Version: 8.15.2
Release Notes: Date Time Utilities is available in 8 version
Version: 1.1.0
Framework Version: 7.23.11
Release Notes: Added some java actions for Date time
Version: 1.0.0
Framework Version: 7.23.11
Release Notes: First Release!!!