How to format datetime?

  • Thread starter Thread starter Vinitha
  • Start date Start date
V

Vinitha

Hi,
I 've ("9/27/2003 12:11:31 PM") this value in database .
i need to get only this value ("9/27/2003 " ) .How will i format it to get
this value?

It will be helpful if some one could point me to some code sample for the
same

thank you in advance
 
Hi

Construct new Datetime values from value in database
DateTime dt = new DateTime(databasevalue)
then use dt.Date.

HTH
Ravikanth[MVP]
 
if you want string, you can use:

DateTime aDateTime = getDateTimeFromDB(some criteria);
string str = aDateTime.Value.ToShortDateString();
 
Vinitha said:
Hi,
I 've ("9/27/2003 12:11:31 PM") this value in database .
i need to get only this value ("9/27/2003 " ) .How will i format it to get
this value?

It will be helpful if some one could point me to some code sample for the
same

thank you in advance

DateTime theDate .....
theDate.ToString("m/d/yyyy");

if it is the string representation that you want.
 

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

Excel How to add numbers in same cell? 2
DateTime 8
Missed Opportunity 3
Windows 7 Duplicate files. 1
Databinding to a grid - DateTime problem 7
Date formatting on DateTime? 4
DateTime 5
How to parse a string to datetime without a time 9

Back
Top