Friday, February 25, 2011

Formating DateTime

if u want to save with AM/PM

Example 1:
1. string strSecond = (System.DateTime.Now).ToString("dd-MMM-yyyy hh:mm tt");


if u want to save only date
2. string strSecond = (System.DateTime.Now).ToString("dd-MMM-yyyy ");


Example 2:
1. string strSecond = "25-01-2001"; (or)  "2011-01-25";.ToDateTime(strSecond ).ToString("dd-MMM-yyyy hh:mm tt");
     Convert

Make sure that u have to convert to DB the dateFormat from stringParam which we are sending.

No comments: