Skip to main content

A customer recently asked me how could a form default to the next first Friday of the month. If the current date was passed the first Friday of the month, select the next month. A complex idea, but I found a way to solve this through a complex formula.

 

The video explains how to solve this, or the formula is included below if you wanted to reuse the example, or download the example form.

 

ifElse(formatdate(dateadd("Days",0,dateNow()),"ddd") == "Fri" && converttonumber(formatdate(dateadd("Days",0,dateNow()),"D")) < 8, dateadd("Days",0,dateNow()),ifElse(formatdate(dateadd("Days",1,dateNow()),"ddd") == "Fri" && converttonumber(formatdate(dateadd("Days",1,dateNow()),"D")) < 8, dateadd("Days",1,dateNow()),ifElse(formatdate(dateadd("Days",2,dateNow()),"ddd") == "Fri" && converttonumber(formatdate(dateadd("Days",2,dateNow()),"D")) < 8, dateadd("Days",2,dateNow()),ifElse(formatdate(dateadd("Days",3,dateNow()),"ddd") == "Fri" && converttonumber(formatdate(dateadd("Days",3,dateNow()),"D")) < 8, dateadd("Days",3,dateNow()),ifElse(formatdate(dateadd("Days",4,dateNow()),"ddd") == "Fri" && converttonumber(formatdate(dateadd("Days",4,dateNow()),"D")) < 8, dateadd("Days",4,dateNow()),ifElse(formatdate(dateadd("Days",5,dateNow()),"ddd") == "Fri" && converttonumber(formatdate(dateadd("Days",5,dateNow()),"D")) < 8, dateadd("Days",5,dateNow()),ifElse(formatdate(dateadd("Days",6,dateNow()),"ddd") == "Fri" && converttonumber(formatdate(dateadd("Days",6,dateNow()),"D")) < 8, dateadd("Days",6,dateNow()),ifElse(formatdate(date(converttonumber(formatDate(dateNow(),"YYYY")),converttonumber(formatDate(dateNow(),"M")) + 1,1),"ddd") == "Fri",date(converttonumber(formatDate(dateNow(),"YYYY")),converttonumber(formatDate(dateNow(),"M")) + 1,1),ifElse(formatdate(date(converttonumber(formatDate(dateNow(),"YYYY")),converttonumber(formatDate(dateNow(),"M")) + 1,2),"ddd") == "Fri",date(converttonumber(formatDate(dateNow(),"YYYY")),converttonumber(formatDate(dateNow(),"M")) + 1,2),ifElse(formatdate(date(converttonumber(formatDate(dateNow(),"YYYY")),converttonumber(formatDate(dateNow(),"M")) + 1,3),"ddd") == "Fri",date(converttonumber(formatDate(dateNow(),"YYYY")),converttonumber(formatDate(dateNow(),"M")) + 1,3),ifElse(formatdate(date(converttonumber(formatDate(dateNow(),"YYYY")),converttonumber(formatDate(dateNow(),"M")) + 1,4),"ddd") == "Fri",date(converttonumber(formatDate(dateNow(),"YYYY")),converttonumber(formatDate(dateNow(),"M")) + 1,4),ifElse(formatdate(date(converttonumber(formatDate(dateNow(),"YYYY")),converttonumber(formatDate(dateNow(),"M")) + 1,5),"ddd") == "Fri",date(converttonumber(formatDate(dateNow(),"YYYY")),converttonumber(formatDate(dateNow(),"M")) + 1,5),ifElse(formatdate(date(converttonumber(formatDate(dateNow(),"YYYY")),converttonumber(formatDate(dateNow(),"M")) + 1,6),"ddd") == "Fri",date(converttonumber(formatDate(dateNow(),"YYYY")),converttonumber(formatDate(dateNow(),"M")) + 1,6),ifElse(formatdate(date(converttonumber(formatDate(dateNow(),"YYYY")),converttonumber(formatDate(dateNow(),"M")) + 1,7),"ddd") == "Fri",date(converttonumber(formatDate(dateNow(),"YYYY")),converttonumber(formatDate(dateNow(),"M")) + 1,7),dateNow()))))))))))))))

Be the first to reply!

Reply