Convert datetime to date
-
Hi.. i want to convert datatime format to Date...i want to display On UI only date... I am using below method its not working for me... can anyone suggest me..
public static String GetShortDate(String sDateTimeValue) { return String.Format("{0:dd/MM/yy}", sDateTimeValue.ToString()); }
-
Hi.. i want to convert datatime format to Date...i want to display On UI only date... I am using below method its not working for me... can anyone suggest me..
public static String GetShortDate(String sDateTimeValue) { return String.Format("{0:dd/MM/yy}", sDateTimeValue.ToString()); }
public static String GetShortDate(String sDateTimeValue)
{
DateTime _date = DateTime.Parse(sDateTimeValue);
return _date.ToString("d", DateTimeFormatInfo.InvariantInfo);
}Have a look at the various formats here[^]
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
modified on Tuesday, June 23, 2009 4:09 AM
-
public static String GetShortDate(String sDateTimeValue)
{
DateTime _date = DateTime.Parse(sDateTimeValue);
return _date.ToString("d", DateTimeFormatInfo.InvariantInfo);
}Have a look at the various formats here[^]
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
modified on Tuesday, June 23, 2009 4:09 AM
Hey..i tried with above method..i followed other methods also which you send me ..i,e very good link for beginners like me....eventhough i couldn't resolve that issue.. its throwing exception error like below.. FORMAT EXCEPTION UNHANDLED BY USERCODE... converting from string to datetime parse the string to take the date before putting each variable datetime object into How can i resolve ???