Format for Date.

  • Thread starter Thread starter Phoebe.
  • Start date Start date
P

Phoebe.

Hi, Good Day!

In my SQL database, my PostedDate's datatype is not Date/Time but integer
for eg. 20040310

I'd like to show the date in this format --> 10/03/2004 in my datagrid, so
how can i do tht?

Can someone help?
Thanks in advanced.

rgds,
Phoebe.
 
Not sure if there is a ready CLR function for doing it, but the small
function below should do the trick (assume the integer date is allways 8
digits).

string getFormatedDate (int date)
{
string s = date.ToString();
return s.Substring(6,2) + "/" + s.Substring(4,2) + "/" +
s.Substring(0,4);
}
 
Back
Top