Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Return Quarter of last month
#1
Hi guys,

i'm new here, my first post Smile

So i need for several macros and autotext a global variable that contains the quarter of the last month.

- We have now November 2021 so the question is: To which quarter belongs October 2021 (previous month)?
- Send me this back in a variable (letztesQuartal) in this Style (October = 4th quarter in 2021): Q4/2021.
- This runs as function once when i start QM.

I get what i want with my code.  But i guess it could be written much better.
Any ideas?

Thanks for your ideas and stay healthy
Achim
Code:
Copy      Help
 
function'str

str Monat
str brauchbaresMonatsDatum
DateTime pcDatum.FromComputerTime

pcDatum.AddMonths(-1) ;; calc previous month
Monat = brauchbaresMonatsDatum.timeformat("{MM}" pcDatum) ;;format to month

int rechner = val(Monat) ;; val = converter like .ToInteger
rechner = (rechner + 2) / 3 ;; Formula if Ceiling isn't available

;; pull Year
str brauchbaresJahresDatum
str Jahr

Jahr = brauchbaresJahresDatum.timeformat("{yyyy}" pcDatum) ;;format Year

str Teileins
str Teilzwei
str Teildrei
str Teilvier

Teileins = "Q"
Teilzwei = rechner
Teildrei = "/"
Teilvier = Jahr

str+ letztesQuartal ;; str+ sets global available variable

letztesQuartal.from(Teileins Teilzwei Teildrei Teilvier)

out letztesQuartal


Messages In This Thread
Return Quarter of last month - by BoolTaxCoder - 11-14-2021, 09:34 AM
RE: Return Quarter of last month - by Kevin - 11-15-2021, 02:17 AM
RE: Return Quarter of last month - by Kevin - 12-04-2021, 09:06 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)