I have found this list on the forum and seems like a good approach.
1 - 20 Capricorn
21 - 49 Aquarius
50 - 79 Pisces
80 - 110 Aries
111 - 140 Taurus
141 - 171 Gemini
172 - 203 Cancer
204 - 234 Leo
235 - 265 Virgo
266 - 295 Libra
296 - 325 Scorpio
326 - 355 Sagittarius
356 - 365 Capricorn
So, When user enters their birthday do the following:
- Convert birthdate to day of the year (e.g 20 feb is the 41th day of the year)
- For each of the ranges save the zodiac sign in the database and display it to the user.
Q1. How should I calculate the day of the year from a birthday?
Q2. what’s the best way to implement ?
Q3 Is there any better way to implement the above use case?
Hi there, @theswati15… if I was doing what you described, I would likely start by creating an option set that has the zodiac signs as the options. The option set would also have two attributes (number) that would be used to define the range for each sign.
As far as calculating the day of the year from a birthday goes, there might be multiple ways to go about it, but this works.
In words, the expression gets the last day of the current year and subtracts the user’s birthday from it (with the user’s birth year changed to the current year) and then subtracts 365 from that number and multiplies by -1. I’m sure you could do 365 minus the expression to avoid having to multiply by -1, but you get the point. Oh, and if your next question is how did I get the parentheses in there, make sure to enable the experimental parentheses feature.
Then, once you have the user’s birthday converted to the day of the year, get the option from the option set where the resulting day is greater than or equal to the lower number in the option’s range and less than or equal to the higher number in the option’s range, and you’re good to go.
Hope this helps.
P.S. 20 Feb is the 51st day of the year, not the 41st… you really threw me off there and had me thinking my expression wasn’t working when I tried it with that date.
Thank you @mikeloc that was very detailed I completely got it. I had been thinking about the same but your provided the formula which is really appreciated.
Could you please give more detail about how I can use the option set range to find zodiac signs using workflow or dynamic formula in the text’s appearance?
This topic was automatically closed after 70 days. New replies are no longer allowed.