views:

314

answers:

4

i try to write any code about days:

function xyz("13.02.2009") { return value= 6; }

function xyz("12.02.2009") { return value= 5; }

function xyz("14.02.2009") { return value= 7; }

but how?

tihs method is good but i need C# times specific codes(like timespan...)



            DayOfWeek day = DateTime.ParseExact("13.02.2008", "dd.MM.yyyy", CultureInfo.InvariantCulture).DayOfWeek;
            int days = ((int)day - (int)DateTime.Now.DayOfWeek);
            if (days <= 0) days += 7;
            Console.Write(days);

A: 
return (int)(myDateTime.DayOfWeek);
teedyay
+1  A: 

It's DateTime.DayOfWeek what you need. And a decent C# book.

Anton Gogolev
+3  A: 

Note that DateTime.DayOfWeek depends on your regional settings.

Gerrie Schenck
+1  A: 
DateTime day = DateTime.ParseExact("13.02.2008", "dd.MM.yyyy",CultureInfo.InvariantCulture);
TimeSpan difference = day.Subtract(DateTime.Now);
int days = difference.Days;
Sessiz Saat
Dude, is it so hard to add "+ 1"?
Anton Gogolev