Skip to main content
December 10, 2023
Question

how to extract year from date and time with timezone

  • December 10, 2023
  • 5 replies
  • 0 views

I have record which has " created on "field. I wanted to filter all records that is created for this year. But when I try to convert the created on field to year for comparison. It shows error. 

Expression evaluation error at function a!queryRecordType: Could not cast from Record Field to Date. Details: CastInvalidCould not cast from Record Field to Date. Details: CastInvalid

Any help is appreciated

    5 replies

    stefanhelzle0001
    Brainy
    December 10, 2023

    Can you share a few more details? Code snippets?

    Did you consider to use a custom record field that just holds the year part of that date?

    niranjanreddym9323
    December 11, 2023

    Hi [mention:92ba06295fbc4d77b281c512999a858b:e9ed411860ed4f2ba0265705b8793d05] ,

    You can create a custom record field  'year' using extract partial dates template and refer this new custom field to filter the data that is created for this year.

    konduruc733182
    December 11, 2023

    Hello kowsalyav7826,

    Create a custom record field shown as below



    Then Create a user filter from the Filters in a expression mode

    Here's a code snippet if needed for reference, replace the field here with your custom record field value and test it out.

    a!localVariables(
      local!year:a!queryRecordType(
        recordType: 'recordType!{55d40bd2-3986-4477-bd9f-627d5a979404}STE Asset Request',
        fields: a!aggregationFields(
          groupings: {
            a!grouping(
              field: 'recordType!{55d40bd2-3986-4477-bd9f-627d5a979404}STE Asset Request.fields.{0c614836-7916-4250-acf6-a19403f6dd18}raisedonYear',
              alias: "year"
            )
          }
        ),
        pagingInfo: a!pagingInfo(startIndex: 1,batchSize: 5000)
      ).data,
      a!recordFilterList(
        name: "Year",
        options: a!forEach(
          items: index(local!year,"year",""),
          expression: a!recordFilterListOption(
            id: fv!index,
            name: fv!item,
            filter: a!queryFilter(
              field: 'recordType!{55d40bd2-3986-4477-bd9f-627d5a979404}STE Asset Request.fields.{0c614836-7916-4250-acf6-a19403f6dd18}raisedonYear',
              operator: "=",
              value: fv!item
            )
          )
        )
      )
    )

    Below is the outcome of the above 

    December 11, 2023
    [deleted]
    konduruc733182
    December 11, 2023

    I don't understand the audacity of these people creating accounts and making such post on a platform which is completely dedicated to Technical knowledge sharing. I think there should be more aggressive measures on such accounts.