Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Count Day of Week Within Current Month From Current Date

Avatar

Level 1

I am trying to create a script to calculate how many Mondays, Tuesdays, Wednesdays, etc. are left from the current date within the current month.  I do not know how to go about this.   Any and all help is appreciated.  Thank you in advance.

1 Reply

Avatar

Level 10

Hi,

this is not too difficult to do in FormCalc.

Use this code in a calculate:Event of a text field or numeric field.

It counts how many mondays this month already has had.

var todaysDate = Date2Num(MyDateField1.formattedValue, "DD.MM.YYYY")

var dayNumber = Num2Date(todaysDate, "D")

var dayCount = 0


for i = dayNumber downto 1 step 1 do

     if (Num2Date(todaysDate - i, "E") eq 2) then

          dayCount = dayCount + 1

     endif

endfor


$ = dayCount