Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Return Quarter of last month
#2
There is really no need to use a global variable here or have the function run at startup.
You can call it on demand using a function and local variables easy.
Can also simplify the code a bit.

create a Function and call that function from code when ever you need the value.

Function QuarterOfLastMonth
Code:
Copy      Help
function str&lq 
DateTime pcDatum.FromComputerTime
pcDatum.AddMonths(-1) ;; calc previous month
lq.from("Q" (val(pcDatum.ToStrFormat("{MM}")) +2 /3) "/" pcDatum.ToStrFormat("{yyyy}"))

call this function any other function or macro 
example from another function or macro
Function Function4
Code:
Copy      Help
str letztesQuartal; QuarterOfLastMonth(letztesQuartal)
out letztesQuartal

for Autotext can call it like this.
Two possible ways shown below.
One using a subfunction to call the function and one without using a subfunction at all.

Autotext Autotext18
Trigger $t     Help - how to add the trigger to the macro
Code:
Copy      Help
/b/i/c
lq :sub.Sub1;;Get Quarter of last month
glq :QuarterOfLastMonth(_s);paste+ _s;;;;Get Quarter of last month
#sub Sub1
QuarterOfLastMonth(_s)
paste+ _s


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)