naveen.s
(Naveen S)
January 22, 2025, 6:34am
1
Hello All,
I need to get the previous quarter of the current financial year as below:
–>I need to get the first quarter in the form of Q1( between the months July to September)
–>I need to get the second quarter in the form of Q2( between the months October to December)
–>I need to get the third quarter in the form of Q3(between the months Jan to march)
–>I need to get the four quarter in the form of Q4((between the months April to June).
Please help on this
@naveen.s ,
Use this in assign activity
previousQuarter = If(DateTime.Now.Month >= 4 AndAlso DateTime.Now.Month <= 6, "Q3",
If(DateTime.Now.Month >= 7 AndAlso DateTime.Now.Month <= 9, "Q4",
If(DateTime.Now.Month >= 10 AndAlso DateTime.Now.Month <= 12, "Q1", "Q2")))
Anil_G
(Anil Gorthi)
January 22, 2025, 6:41am
3
@naveen.s
this should do the job
If({1,2,3}.contains(Now.Month),"Q3",If({4,5,6}.contains(Now.Month),"Q4",If({7,8,9}.contains(Now.Month),"Q2","Q1")))
cheers
@naveen.s ,
My bad it’s returning previous to previous quarter. Here is revised logic to get last quarter.
previousQuarter = If(DateTime.Now.Month >= 4 AndAlso DateTime.Now.Month <= 6, "Q4",If(DateTime.Now.Month >= 7 AndAlso DateTime.Now.Month <= 9, "Q1", If(DateTime.Now.Month >= 10 AndAlso DateTime.Now.Month <= 12, "Q2", "Q3")))
1 Like
naveen.s
(Naveen S)
January 22, 2025, 7:29am
5
Anil_G:
If({1,2,3}.contains(Now.Month),“Q3”,If({4,5,6}.contains(Now.Month),“Q4”,If({7,8,9}.contains(Now.Month),“Q2”,“Q1”)))
Thanks also I want get the year as well as below:
Q1 2024
Q2 2024
Q3 2024
Q4 2025
A single Space between (Quarter and Year)
Anil_G
(Anil Gorthi)
January 22, 2025, 7:32am
6
@naveen.s
use this
If({1,2,3}.contains(Now.Month),"Q3 " + Now.Year.ToString,If({4,5,6}.contains(Now.Month),"Q4 " + Now.Year.ToString,If({7,8,9}.contains(Now.Month),"Q2 " + Now.Year.ToString,"Q1 " + Now.addyears(1).Year.ToString)))
basically now.addyears(-1).year will give previous year
now.year will give current
now.addyears(1).year will give next year
adjust the year if you need
cheers
Anil_G
(Anil Gorthi)
January 22, 2025, 8:03am
8
@naveen.s
Can you please use the above one
Or you need to complete it like this
dateprevquarterdate + If((datePrevQuarterDate).Contains("Q1"), now.ToString("yyyy"),now.addyears(-1).ToString("yyyy"))
This gives Q1 2025 or Q2 2024 or Q3 2024 or Q4 2024
Cheers
1 Like