Filter record based on mid of the month

Certified Associate Developer

Hello All, i am trying to filter the record which has been created in the 1st half of that particular month. So basically,  I have a record with a column "Created on" (Data type).

on this column, i have to apply the filter to get the records which have been created in the 1st half of the month. For eg. if record created on "11/10/2023, it is created in the 1st half (Before 16th October and so on.

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    This solution takes into account the fact that months have varying amounts of days. (28, 29, 30, 31) and that the mid way point can change.

    a!localVariables(
      /* Get current datetime */
      local!now: now(),
      /* Get datetime for end of month */
      local!endDate: eomonth(local!now, 0),
      /* Get the day from end of month datetime */
      local!endOfMonthDay: day(local!endDate),
      /* Find the middle of the month */
      local!midMonthDay: tointeger(round(local!endOfMonthDay / 2, 0)),
      /* Calculate start and end dates */
      local!startDateTime: userdatetime(
        year(local!endDate),
        month(local!endDate),
        1,
        0,
        0,
        0
      ),
      local!endDateTime: userdatetime(
        year(local!endDate),
        month(local!endDate),
        local!midMonthDay,
        23,
        59,
        59
      ),
      {
        startDateTime: local!startDateTime,
        endDateTime: local!endDateTime
      }
    )

Reply
  • +1
    Certified Lead Developer

    This solution takes into account the fact that months have varying amounts of days. (28, 29, 30, 31) and that the mid way point can change.

    a!localVariables(
      /* Get current datetime */
      local!now: now(),
      /* Get datetime for end of month */
      local!endDate: eomonth(local!now, 0),
      /* Get the day from end of month datetime */
      local!endOfMonthDay: day(local!endDate),
      /* Find the middle of the month */
      local!midMonthDay: tointeger(round(local!endOfMonthDay / 2, 0)),
      /* Calculate start and end dates */
      local!startDateTime: userdatetime(
        year(local!endDate),
        month(local!endDate),
        1,
        0,
        0,
        0
      ),
      local!endDateTime: userdatetime(
        year(local!endDate),
        month(local!endDate),
        local!midMonthDay,
        23,
        59,
        59
      ),
      {
        startDateTime: local!startDateTime,
        endDateTime: local!endDateTime
      }
    )

Children
No Data