February 29, 20169 yr I'm trying to set up a button bar that displays the current months names based on the following Current month Last month Next Month I can use Month (Get(current date)) - 1 (for example) but I get a number of 2 for february or 1 for january If I use Monthname (Get (Currentdate) - 1 my result is (-1) Thanks in advance, thanks!
February 29, 20169 yr 1 hour ago, Matthew R White said: If I use Monthname (Get (Currentdate) - 1 my result is (-1) If you subtract 1 from the current date, you get the date of yesterday, not a date in the previous month. And if you subtract 1 from a month's name (text), then you get -1 (since text is evaluated as 0). To calculate the name of the previous month, you can use = MonthName ( Date ( Month ( Get ( CurrentDate ) ) - 1 ; 1 ; 2 ) ) Edited March 1, 20169 yr by comment
March 1, 20169 yr 7 hours ago, comment said: To calculate the name of the previous month, you can use = MonthName ( Date ( Month ( Get ( CurrentDate ) ) - 1 ; 1 ; 2 ) ) Hi Michael! Would you be so kind as to explain something for me? Of course Get ( CurrentDate ) will never be empty, and since button bar is a layout object, it will always refresh that date (unlike a calculation field which must be checked as 'Do not store calculation results' when using Get ( CurrentDate ). My question ... If I use a regular date field and if that date field is empty then it generates November. I cannot spot the translation logic as to why! Also, if regular date field is used as a calculation, it will not produce a result if your date field is empty because default is checked 'do not evaluate if all referenced fields are empty' so that is great. But if regular date is used on button bar, it should be wrapped with an If() test to not display the result (or to display different default result) if empty because non-field calculations (button bar, script etc) can not take advantage of that 'do not evaluate' checkbox. What fun! Thank you for always throwing surprises into the mix! Is it as simple as Month 1 is January so Month 0 is December ... then previous month is November? Edited March 1, 20169 yr by LaRetta
March 1, 20169 yr 5 hours ago, LaRetta said: Is it as simple as Month 1 is January so Month 0 is December ... then previous month is November? Yes, it is. You can see that: Date ( Month ( "" ) - 1 ; 1 ; 2 ) is Nov 1, 0001. Strictly speaking, Month ( "" ) is not 0, but empty - but when you subtract a number from it, it's as good as.
Create an account or sign in to comment