Days in the previous month expression?

Does anyone know of an expression that gives days in the previous month? I use to use an array to account for leap year and non leap year. But since we can’t use scripting….

Thanks in advance.

this should work (including leap year solution)

({dn} == 3 ? (28 + {ly}) : ({dn} == 5 || {dn} == 7 || {dn} == 10 || {dn} == 12 ? 30 : ({dn} == 1 ? 31 : ({dn} == 2 ? 31 : ({dn} == 4 ? 31 : ({dn} == 6 ? 30 : ({dn} == 8 ? 31 : ({dn} == 9 ? 30 : 31))))))))

or this is even more simple =>

({dn} == 1 ? 31 : ({dn} == 3 ? (28 + {ly}) : ({dn} == 5 || {dn} == 7 || {dn} == 10 || {dn} == 12 ? 30 : 31)))

Thank you! I’ll give it a try when I get a chance.

I had to change it to

{dd} == 2 ? {dd}-1 : {dn} == 5 ? 30 : {dn} == 7 ? 30 : {dn} == 10 ? 30 : {dn} == 12 ? 30 : {dn} == 1 ? 31 : {dn} == 2 ? 31 : {dn} == 4 ? 31 : {dn} == 6 ? 31 : {dn} == 8 ? 31 : {dn} == 9 ? 31 : {dn} == 11 ? 31 : {dy}%4==0 ? 29 : 28

looks great - thanks for update

Ok after bashing my way through this I finally figured everything out. Changing back to Lua helped. Since I kept forgetting that I could do “and” “and” “or”.

{dd} == {ddim} and {dn} == 5 and 30 or {dd} == {ddim} and {dn} == 7 and 30 or {dd} == {ddim} and {dn} == 10 and 30 or {dd} == {ddim} and {dn} == 12 and 30 or {dd} == {ddim} and {dn} == 1 and 31 or {dd} == {ddim} and {dn} == 2 and 31 or {dd} == {ddim} and {dn} == 4 and 31 or {dd} == {ddim} and {dn} == 6 and 31 or {dd} == {ddim} and {dn} == 8 and 31 or {dd} == {ddim} and {dn} == 9 and 31 or {dd} == {ddim} and {dn} == 11 and 31 or {dd} == {ddim} and {dn} == 3 and {dy}%4==0 and 29 or {dd} == {ddim} and {dn} == 3 and 28 or {dd} == 1 and 1 or {dd}-1