Date time without name of day
HI Everybody,
I have this:
[code]
public static IEnumerable<SelectListItem> GetWeekNumbers(this HtmlHelper helper /*Dictionary<int, DateTime> dayOfWeek*/ /*,DateTime allWeeks*/ /*int selectID*/)
{
var janFirst = new DateTime(DateTime.Today.Year, 1, 1);
//beware different cultures.
var firstWeek = janFirst.AddDays(1 - (int)(janFirst.DayOfWeek));
int j = -1;
foreach (var weekNumber in Enumerable.Range(0, 52).Select(i => new
{
weekStart = firstWeek.AddDays(i * 7),
//Tuesday = firstWeek.AddDays(i * 3)
}).TakeWhile(x => x.weekStart.Year <= janFirst.Year).Select(x => new
{
x.weekStart,
//tuesday = x.weekStart.AddDays(3),
weekFinish = x.weekStart.AddDays(6)
}).SkipWhile(x => x.weekFinish < janFirst.AddDays(1)))
{
j++;
yield return new SelectListItem
{
Value = new
{
Monday = firstWeek.AddDays(j * 7).ToString("d"),//.OrderBy(item => item.ToString(CultureInfo.InvariantCulture)),
Tuesday = weekNumber.weekStart.AddDays(1).ToShortDateString(),
Wendsday = weekNumber.weekStart.AddDays(2).ToShortDateString(),
Thursday = weekNumber.weekStart.AddDays(3).ToShortDateString(),
Fryday = weekNumber.weekStart.AddDays(4).ToShortDateString(),
Saterday = weekNumber.weekStart.AddDays(5).ToShortDateString(),
Sunday = weekNumber.weekStart.AddDays(6).ToShortDateString(),
}.ToString(),
Text = (j + 1).ToString(CultureInfo.InvariantCulture)
};
//foreach (var week in weekNumber)
//{
//string s = string.Format("{}")
}
//return helper.DropDownList()
}//end me
[/code]
But I get in the textbox this output:
{ Monday = 9-1-2012
But the output has to be only the date, like this: 9-1-2012
THX for helping.
Niels.