Date offset in repeater

Hi,
May I please ask if anybody could advise how to adjust date offset in the repeater? 0, 1, 2, 7 days ago.

[[Now.getMonthName(Item.dateOffset)]] [[Now.getDate(Item.dateOffset)]], [[Now.getFullYear()]] [[Now.addHours(0).toLocaleTimeString().substring(0,4)]] [[Now.toLocaleTimeString().substring(8,10)]] [[Now.substr(Now.indexOf('(')+1,1)]]ST

Preview
pop-up-date-offset.rp (110.8 KB)
Thanks,
Natalie

Hi Natalie!

Example 5 in this Medium article on understanding the repeater covers that exact topic. Let me know if you can’t access it.

1 Like

Hi Joseph, I corrected script:

[[Now.addDays(Item.dateOffset).getMonthName()]] [[Now.addDays(Item.dateOffset).getDate()]], [[Now.addDays(Item.dateOffset).getFullYear()]] [[Now.addHours(0).toLocaleTimeString().substring(0,4)]] [[Now.toLocaleTimeString().substring(8,10)]] [[Now.substr(Now.indexOf(’(’)+1,1)]]ST

image
And it’s working :slight_smile: Thank you for sharing an article.
Regards,
Natalie

Hi Joseph!

May I please ask you if, by any chance, you might have an advise for my only remaining issue: the need to have an empty ‘dateOffset’ cell (or a ‘-’ text) for the instances where the status of the correlated cell in the status column dynamically changes from the status that requires a date to the status that requires no date (in my case, this is an undetermined time in the future)?

image
Thank you,
Natalie

Hi Natalie!

Yes, you can do this with conditional logic. E.g.

OnItemLoad
  IF true
    // do all of the non-date stuff, if there is any non-date stuff to do
  IF [[Item.dateOffset]] is equal to "-"  //don't use the quotes, and make sure this is an IF not an ELSE IF 
    // do whatever you need to do when dateOffset is N/A
  ELSE IF
    // do the date conversion here

Example 4 in that same Medium article discusses using conditional logic in a repeater.

Let me know if you need more help!

1 Like

Hi Joseph,
Thank you so much for your help!
I tried to use your script.
But I can’t figure out how to fix a ‘start date’ for ‘In Queue status’:
test-dates.rp (100.9 KB)

Hi!

I think I see the issue: you have two IFs for checking whether each date offset is N/A, but you have only one ELSE, which means the else is executing only when the second IF is false. Try setting it up this way:

OnItemLoad
  IF true
    // do all of the non-date stuff
  IF [[Item.dateOffset1]] is equal to "-" 
    // do whatever you need to do when dateOffset1 is N/A
  ELSE IF
    // do the date conversion for dateOffset1 here
  IF [[Item.dateOffset2]] is equal to "-"  
    // do whatever you need to do when dateOffset2 is N/A
  ELSE IF
    // do the date conversion for dateOffset2 here

Be careful with the IFs and Elses, of course.

1 Like

Hi Joseph,
Thank you very much for explaining a concept of I’F/ELSE IF’! Really appreciate it! :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.