Wednesday, March 28, 2012

trouble creating a zodiac sign web service...

I would like to create a web service that returns the zodiac sign of a given date.

The problem I am having is that I have no idea how to do the following:

I receive a DateTime object with the date as a ShortDateFormat (e.g. 3/1/2005), and I would like to compare this to make sure it falls within a range of dates (compare it to a date range of February 20- March 20 for example) and it returns true. At which point I return the String "Pisces."

Any help on how to do this is greatly appreciated. The problem I don't understand is how to compare a date to a date range and see if it falls within it or not!

Thanks in advance
~nK~

p.s. sorry if this is in the wrong section but I posted in XML Web Services as well :)Hi,
As far as I know there is no scalar to range comparison. Use simple search algorithm to locate relevant range. You can sort your zodiac date ranges by starting date, compare your input date to starting date, until you find first starting date greater then input date, use previous range.
yea or convert all the days to a numeric day of the year (0-364(5) or 1-365(6)), then set numeric ranges for all the zodiac signs (100-131 = pices for example), then you can convert the entered date to a number and tell where it "fits in" to the zodiac ranges.
I created the service using a select statement on the month part alone.

Then each case is for each month, and then it has an if to say whether it is less than or equal to a specific day at which point it returns the correct zodiac sign.

For example, if I put in the date 3/1/05 it should return Pisces.

Select Month(dateObj)
Case 3
If Day(dateObj) <=21 Then
return "Pisces"
Else: Return "Aries"

and so on...

Of course the dateObj is the date that is returned.

Now I am trying to make the date not be cultural specific. Any ideas how this is done?
Basically, in some parts of the world they enter the date as dd/mm/yy but in other parts its mm/dd/yy. So that's what I meant by not cultural specific.

Thanks.
~nK~

0 comments:

Post a Comment