Skip to main content
juhin790475
April 9, 2024
Question

Date being single element in array vs Date being one of the elements in array

  • April 9, 2024
  • 4 replies
  • 0 views

I have a value of type Date, inside two arrays. 
First array has only one value,
Second array has multiple values. 

When I try to evaluate their typeOf(), 
I get 54 (Date with Timezone) for first one, 

I get 7 (Date) for second one.

The question is, why does the data type change for todate(now()) in first and second array ?



Code:

a!localVariables(
  local!singleItem: { todate(now()) },
  local!listOfVariant: { 2, todate(now()) },
  {
    typeOfSingleItem: a!forEach(
      items: local!singleItem,
      expression: typeof(fv!item)
    ),
    typesOfListOfVariant: a!forEach(
      items: local!listOfVariant,
      expression: typeof(fv!item)
    )
  }
)


Screenshot:

4 replies

daniell
April 9, 2024

It's hard to say for sure, but it seems like the "List of Variant" type does not support items of type "Date and Timezone", so they get converted to the regular "Date" type. I generally try to avoid List of Variant if possible because it often causes unexpected behavior like this

davidj137213
April 9, 2024

As [mention:89ec515a02ff4fa28317edeb40cf0a4d:e9ed411860ed4f2ba0265705b8793d05]  said, sometimes the variant list has different behavior.


In your case, you can check that by changing the first component of the second array, the returned type is again 54.

stefanhelzle0001
April 10, 2024

While I know that there is Date and Date with Timezone, did you guys see any difference in behaviour of these two types? I did not.