first quarter = 1st May 2022 to 1st Aug 2022
second quarter = 1st Aug to 1st Nov
third quarter = 1st Nov to 1st Feb
fourth quarter = 1st Feb to 1st May
My question is if date is for eg 6th July 2022 (date will be dynamic) it should give message as lies in First quarter
If date changes it should return their respective quarters
this will return quarter month
but how to check in which quarter is the date for eg 6th july
date will be dynamic which is coming from GetText activity
and then i want to check gettext date lies in which quarter then proceed after
My question is that if the date is in fixed format like βMM/dd/yyyyβ with no (th,st,nd,rd,d) for this is there any need of Regex?
If no what will be the approach?
A date has no format. A date is a date. If your date is in string format convert it to a valid DateTime datatype first. Use one of the many dateTime.parseExact examples.
You can then calulate a quarter relatively simple.
Divide your dateVar.moth by 3, and round the value up to an integer.
So you get:
math.ceiling(myDate.month / 3)
Resulting in:
january β 1 /3 β 1
february β 2 /3 β 1
march β 3 /3 β 1
aprilβ> 4 /3 β 2
β¦
β¦
november β 11 /3 β 4
december β 12 /3 β 4
After getting the desired quarter i want to use switch case but output is in string format
in switch case i need
if that value is in : Q1 then 25 data should be filled
if Q2 then 50 like that
Will i have to convert string to Int for Switch case?