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);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Change Format for Date 1
Export file to excel 1
Format data in datagrid 2
Exit program 8
Page redirection by clicking image button. 1
Pop out msgbox 3
Date format. 1
Problem formatting dates from CSV file 2

Back
Top