0

We are displaying hours of operation in the footer.The operating hours are different for every center( some are open from Mon-Sat and some from Mon-Sunday)

If i use For @i=1 to 7 do and that center has Mon-Sat as the working days,its throwing me an error. Similarly, If i use For @i=1 to 6 do then its displaying the output but Sunday is showing blank.

My Code :

SET @rows = LookupOrderedRows(@DE, '0','StartTime DESC',"CId",@TestID)

   
 SET @rowCount = rowcount(@rows)
   
 if @rowCount > 0 then

  for @i=1 to 6 do
   SET @row = row(@rows,@i)
   SET @DayOfWeek  =  FIELD(@row, 'DayOfWeek')
   if @DayofWeek == "Monday" THEN
     SET @MonStart = FIELD(@row, 'StartTime')
     SET @MonEnd = FIELD(@row, 'EndTime')
     SET @MStart = FormatDate(@MonStart, "hh:mm")
     SET @MEnd = FormatDate(@MonEnd, "hh:mm")
   ELSEIF @DayofWeek == "Tuesday" THEN
     SET @TueStart = FIELD(@row, 'StartTime')
     SET @TueEnd = FIELD(@row, 'EndTime')
     SET @TuStart = FormatDate(@TueStart, "hh:mm")
     SET @TuEnd = FormatDate(@TueEnd, "hh:mm")
   ELSEIF @DayofWeek == "Wednesday" THEN
     SET @WedStart = FIELD(@row, 'StartTime')
     SET @WedEnd = FIELD(@row, 'EndTime')
     SET @WStart = FormatDate(@WedStart, "hh:mm")
     SET @WEnd = FormatDate(@WedEnd, "hh:mm")
   ELSEIF @DayofWeek == "Thursday" THEN
     SET @ThuStart = FIELD(@row, 'StartTime')
     SET @ThuEnd = FIELD(@row, 'EndTime')
     SET @ThStart = FormatDate(@ThuStart, "hh:mm")
     SET @ThEnd = FormatDate(@ThuEnd, "hh:mm")
   ELSEIF @DayofWeek == "Friday" THEN
     SET @FriStart = FIELD(@row, 'StartTime')
     SET @FriEnd = FIELD(@row, 'EndTime')
     SET @FStart = FormatDate(@FriStart, "hh:mm")
     SET @FEnd = FormatDate(@FriEnd, "hh:mm")
   ELSEIF @DayofWeek == "Saturday" THEN
     SET @SatStart = FIELD(@row, 'StartTime')
     SET @SatEnd = FIELD(@row, 'EndTime')
     SET @SaStart = FormatDate(@SatStart, "hh:mm")
     SET @SaEnd = FormatDate(@SatEnd, "hh:mm")
   ELSEIF @DayofWeek == "Sunday" THEN
     SET @SunStart = FIELD(@row, 'StartTime')
     SET @SunEnd = FIELD(@row, 'EndTime')
     SET @SuStart = FormatDate(@SunStart, "hh:mm")
     SET @SuEnd = FormatDate(@SunEnd, "hh:mm")
 
  ENDIF
   
]%%
 %%[ next @i ]%%
    %%[ else ]%%
    %%[ endif ]%%

My Requirement: Display the working days of the center + If the center is open from Mon-Sat only those 6 days should be in the output

1 Answer 1

2

Iterate the same number of times as there are records in your rowset:

for @i=1 to @rowCount do
    /* Print a row */
next @i

You must log in to answer this question.

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