1

I have a variable that that is pulling from another variable and applying the Field function to it as below.

set @CampaignStartTime = Field(@CampTypeRows,"Event_Time_Text__c")

I now want to apply the function SystemDateToLocalDate to the line above to make the time output localised.

I tried the below but keep getting validation issues:

set @CampaignStartTime = SystemDateToLocalDate(Field(@CampTypeRows,"Event_Time_Text__c"))

Also, worth mentioning I have another block further down the email which is setting new variables using @CampaignStartTime. Will any changes impact my second block?

   set @GoogleStartEndTime = (CONCAT(
   Format(@CampaignDate, "yyyyMMdd")),
   'T',
   Format(@CampaignStartTime, "HHmm"),
   '00Z',
   '%2f',
   Format(@CampaignDate, "yyyyMMdd"),
   'T',
   Format(@CampaignEndTime, "HHmm"),
   '00Z'   
  )

What am I doing wrong? and How can I fix it?

1
  • I would also make sure 'Event_Time_Text__c' is actually a date field. The name implies it's a text version of a date which isn't compatible with date functions. Commented Mar 18, 2020 at 14:01

1 Answer 1

4

I suspect, not having your complete Ampscript, the issue is caused by you not selecting a single row, but applying Field function to multiple rows. Here is what you need to do:

SET @rowCount = rowcount(@CampTypeRows) /* count rows to ensure your lookup returns something */

IF @rowCount > 0 THEN /* only execute this block if you have some results */

  SET @row = row(@CampTypeRows,1) /* get row #1 */
  SET @CampaignStartTime = SystemDateToLocalDate(Field(@row,"Event_Time_Text__c")) /* Convert your date */

ENDIF

Your AmpScript further down the page will work without issues.

1
  • @MJB - remember to mark the answer as accepted Commented Mar 23, 2020 at 10:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .