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);
From stackoverflow
-
return (int)(myDateTime.DayOfWeek);
-
It's
DateTime.DayOfWeek
what you need. And a decent C# book. -
Note that DateTime.DayOfWeek depends on your regional settings.
-
DateTime day = DateTime.ParseExact("13.02.2008", "dd.MM.yyyy",CultureInfo.InvariantCulture); TimeSpan difference = day.Subtract(DateTime.Now); int days = difference.Days;
Anton Gogolev : Dude, is it so hard to add "+ 1"?
0 comments:
Post a Comment