Skip to main content
New Participant
Oct 12, 2022 7:22 AM UTC
Solved

Get month from the date

Hi Team,

I am trying to get the month, day and year from the date time. I was able to filter the records using a query, but the result is in a list type variant. 

I am unable to apply month/day functions to the fv!item.

If i write month[fv!item] i am getting the following error.

"Expression evaluation error at function a!forEach [line 47]: Error in a!forEach() expression during iteration 16: Expression evaluation error at function 'month' [line 56]: A null parameter has been passed."

I believe it is because each individual item is itself a list.

I don't know how to drilldown the list.  fv!item[1] give me another error. 

"Expression evaluation error at function a!forEach [line 47]: Error in a!forEach() expression during iteration 1: Expression evaluation error : Invalid index: Cannot index type Number (Integer) into type Date and Time".

Any help is appreciated. thanks

gabriele.camilli
Employee
Oct 12, 2022 7:43 AM UTC
[quote userid="163011" url="~/discussions/f/data/26201/get-month-from-the-date"]"Expression evaluation error at function a!forEach [line 47]: Error in a!forEach() expression during iteration 1: Expression evaluation error : Invalid index: Cannot index type Number (Integer) into type Date and Time".[/quote]

This happened because you tried to index fv!item, that was a single Date and Time variable

[quote userid="163011" url="~/discussions/f/data/26201/get-month-from-the-date"]"Expression evaluation error at function a!forEach [line 47]: Error in a!forEach() expression during iteration 16: Expression evaluation error at function 'month' [line 56]: A null parameter has been passed."[/quote]

About this you could try a simple 

reject(fn!isnNull, local!reportOn)

If this is not enough look at the element and see which could be the problem

5 replies

harshitb6843
Brainy
Oct 12, 2022 7:25 AM UTC

Can you try using a!flatten() and see if this solves your problem? 

Participating Frequently
Oct 12, 2022 7:36 AM UTC

The month function does not accept null values to handle that apply null check over it.

[quote userid="163011" url="~/discussions/f/data/26201/get-month-from-the-date"]"Expression evaluation error at function a!forEach [line 47]: Error in a!forEach() expression during iteration 16: Expression evaluation error at function 'month' [line 56]: A null parameter has been passed."[/quote]

gabriele.camilli
Employee
Oct 12, 2022 7:43 AM UTC
[quote userid="163011" url="~/discussions/f/data/26201/get-month-from-the-date"]"Expression evaluation error at function a!forEach [line 47]: Error in a!forEach() expression during iteration 1: Expression evaluation error : Invalid index: Cannot index type Number (Integer) into type Date and Time".[/quote]

This happened because you tried to index fv!item, that was a single Date and Time variable

[quote userid="163011" url="~/discussions/f/data/26201/get-month-from-the-date"]"Expression evaluation error at function a!forEach [line 47]: Error in a!forEach() expression during iteration 16: Expression evaluation error at function 'month' [line 56]: A null parameter has been passed."[/quote]

About this you could try a simple 

reject(fn!isnNull, local!reportOn)

If this is not enough look at the element and see which could be the problem

Participating Frequently
Oct 12, 2022 7:45 AM UTC

I think this should be applied to items on line number 48

current code

items: local!reportedOn

Change to 

items:reject(
  fn!isnull,
  a!flatten(
    local!reportedOn
  )
)