Skip to main content
Participating Frequently
Oct 13, 2023 3:52 PM UTC
Question

Custom Field Date time issues

I am trying to determine the shift based on datetime. Here is the use case:

  • Shift 1: 07:00 - 14:59:59
  • Shift 2: 15:00 - 22:59:59
  • Shift 3: 23:00 - 06:59:59

However, it’s not working as expected according to the current code that I have ( Please see the attached screenshot) . The date in Appian writes with GMT adjustment  .

2 replies

mikes0011
Brainy
Oct 13, 2023 4:01 PM UTC

Have you tried explicitly handling NULL values in your a!match() statement?  hour() breaks if passed null.  Just my first guess.

If so, the fix is pretty easy:

The Expression Guru
joseg199Author
Participating Frequently
Oct 13, 2023 4:20 PM UTC

Thank you Mike for the updates. we have fixed the issue by adding a local time zone function a!match(
  value: rv!record['recordType!{942022df-8dbc-4911-b991-b4a48224c936}MECMS Case.fields.{213813ef-766f-4d3d-95c4-3d6963ed19bd}createdOn'],
  whenTrue:and(
    hour(local(fv!value)) >= 7,
    hour(local(fv!value)) < 15
  ),
  then: "Shift 1",
  whenTrue: and(
    hour(local(fv!value)) >= 15,
    hour(local(fv!value)) < 23
  ),
  then: "Shift 2",
  default: "Shift 3",
)