Link to home
Start Free TrialLog in
Avatar of smaguire
smaguireFlag for Canada

asked on

DateTime Compare Function

hi,
I have the following function that returns always 1 no matter what:
for (i = 0; i <= Count - 2; i++) {
            for (j = 0; j <= 6; j++) {                
                 strWeekDay = DateTime.Today.AddDays(DateTime.Compare(DateTime.Today.AddDays(j), StartTime)).ToString("dddd");
...etc
  }
}
When I run it (Today) it always return Saturday!. I tried the compare function on its own and namtter what I enter for the StartTime (DateTime Variable) it always returns 1

I am trying to get the difference between the two sates in Days of the Week (Sunday, Monday...)

any idea how to fix it?
I am using ASP.NET - C#
Avatar of Aaron Jabamani
Aaron Jabamani
Flag of United Kingdom of Great Britain and Northern Ireland image

Can't you use DateTime.Compare() ?
Avatar of smaguire

ASKER

thats what I am using
ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks