Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Count Day of Week Within Current Month From Current Date

Chris1290
Level 1
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
radzmar
Level 10
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