chamara chamara - 1 year ago 71
C# Question

Determine if DateTime is in a given Date Range

Aries March 21 to April 20.
Taurus April 21 to May 20.
Gemini May 21 to June 21.

I need to print the Astrological sign of a user by getting the user's birth month and the date as inputs. How can I get the date range?

EX: March 21 to April 20

Answer Source

You don't actually need to construct a datetime range to solve this. A simple switch statement based on the month with a simple if statement for each month that returns one of two star signs will suffice.

     switch (month)
       case 1:
          if (day <20) return "Capricorn"; else return "Aquarius";
       case 2:
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download