Skip to main content
Solved

Extracting Time from Date Field - But how to avoid #ERROR if date field is blank?

  • September 21, 2021
  • 2 replies
  • 22 views

Hi there,

I am using a formula field to pull the time stamp (and t-zone) from a Date and Time field. I am using this formula currently: DATETIME_FORMAT(SET_TIMEZONE({Day 1 - Start}, ‘America/Los_Angeles’), ‘h:mm a’). This works wonderfully, however, if the time and date field is blank (which, in my case, does happen) my time stamp field shows #ERROR. How can I add to this formula so it knows to leave the field blank if the date and time field is blank?

Would appreciate all and any help on this.

Daniel

Best answer by kuovonne

Wrap your formula in an IF function that tests if there is a value in the date/time field.

IF(
  {Day 1 - Start},
  DATETIME_FORMAT(SET_TIMEZONE({Day 1 - Start}, 'America/Los_Angeles'), 'h:mm a')
)

2 replies

kuovonne
Forum|alt.badge.img+29
  • Brainy
  • Answer
  • September 21, 2021

Wrap your formula in an IF function that tests if there is a value in the date/time field.

IF(
  {Day 1 - Start},
  DATETIME_FORMAT(SET_TIMEZONE({Day 1 - Start}, 'America/Los_Angeles'), 'h:mm a')
)

  • Author
  • Inspiring
  • September 21, 2021

Wrap your formula in an IF function that tests if there is a value in the date/time field.

IF(
  {Day 1 - Start},
  DATETIME_FORMAT(SET_TIMEZONE({Day 1 - Start}, 'America/Los_Angeles'), 'h:mm a')
)

Thank you so much! This was exactly what I was looking for!

So appreciative!
Daniel