views:

4248

answers:

2
+6  A: 
return dateTimeValue.ToString("MM-dd-yyyy");
Mehrdad Afshari
Agreed - from http://msdn.microsoft.com/en-us/library/system.datetime.toshortdatestring(VS.85).aspx the ShortDatePattern of EN-US is "M/d/yyyy", which will trim leading zeros and use "/" as the seperator not "-".
Zhaph - Ben Duguid
@Zhaph: the date is reparsed and passed in the URL so - seperation is necessary.
Chris M
This didn't work for my purposes (in whole) but modifying it to...Convert.ToDateTime(datDate).ToString("MM-dd-yyyy");worked a treat. Thanks
Chris M
A: 

Can't you use the string.Format after you've done the conversion?

ie return string.Format("{0:d}", datDate);

Glenn Slaven
Thats what I Guessed but entering 20-03-2009 produced 3-20-2009
Chris M
Yeah, dunno what I was thinking, Mehrdad's answer is the one that should work
Glenn Slaven