Application Studio Data View row Update calculated Date:

I am attempting to build a dashboard from scratch, the pre-built tool won’t work in this instance.

I have the following row update:

the expression is new Date(Date.now()).getHours() < 4 ? new Date(Date.now() - (8 * 24 * 60 * 60 * 1000)).toISOString().split(‘T’)[0] : new Date(Date.now() - (7 * 24 * 60 * 60 * 1000)).toISOString().split(‘T’)[0]

This correctly sets a string, but when I attempt to set a ‘date’ or ‘datetime’ Data Type, it isn’t updated in the data view.

My population event:


treats the ‘string’ as null because it’s looking for a date.

Does anyone have a suggestion as to what I am doing wrong?

Best regards,
Kevin

Hi Kevin,

I am pretty new as well on this matter and I am learning by doing. Here are some tips I use to get my date and datetime data types working right in my dashboards:

  1. Check the Data Type: Make sure the data type of your field in the data view matches the type you’re setting in your expression (date or datetime).
  2. Watch the Date Format: Make sure the date format in your expression matches what’s expected by the data view. Different systems can have different date format requirements.
  3. Use Date Functions: Try using date functions provided by App Studio, instead of setting a string value directly.

Hope these tips help you sort out your date and datetime data types.

Good luck,

Hila

1 Like

Working with dates in the browser, I’ve had the best luck adding “T00:00:00” to the end:

2024-05-07T00:00:00

Otherwise, it doesn’t recognize things properly - sometimes uses wrong date, sometimes ignores my input altogether

1 Like

Kevin,

Since you are using a BAQ, I recommend that when you’re in the BAQ designer, just add a new calculated field to handle this date conversion.

Here’s how to set it up:

  • Create a Calculation Expression: Just drop in the Date() function to strip off the time part from your DateTime field. You’ll write it like this:

                   `Date(YourDateTimeField)`
    

    This will get you just the date, nice and clean.

  • Use Your New Calculated Field: Now that you’ve got this handy calculated field, you can use it anywhere in your BAQ outputs or for other calculations you need to do.

I hope it helps.

Hila

1 Like