I asked chat gpt to give me a javascript algorithm to find the zodiac sign. this gives you a hint that your records dont need to have both dates just one date. Then you can find all records that are less than your date (rather than extract days/months just create the year of the date as year zero) and the zodiac sign will be the last one
function getZodiacSign(month, day) {
// Zodiac signs and the last day of each sign in each month
const zodiacSigns = {
‘Capricorn’: new Date(0, 0, 20), // January 20
‘Aquarius’: new Date(0, 1, 19), // February 19
‘Pisces’: new Date(0, 2, 20), // March 20
‘Aries’: new Date(0, 3, 20), // April 20
‘Taurus’: new Date(0, 4, 21), // May 21
‘Gemini’: new Date(0, 5, 21), // June 21
‘Cancer’: new Date(0, 6, 22), // July 22
‘Leo’: new Date(0, 7, 23), // August 23
‘Virgo’: new Date(0, 8, 23), // September 23
‘Libra’: new Date(0, 9, 23), // October 23
‘Scorpio’: new Date(0, 10, 22), // November 22
‘Sagittarius’: new Date(0, 11, 21), // December 21
‘Capricorn’: new Date(0, 11, 31) // December 31
};
// Create a date object for the birth date
const birthDate = new Date(0, month - 1, day);
// Find the zodiac sign
for (let sign in zodiacSigns) {
if (birthDate <= zodiacSigns[sign]) {
return sign;
}
}
return 'Capricorn'; // Capricorn starts from December 22 and goes until January 19
}