DateTime convert

D

Dan Bass

Use the ToString() method...

DateTime myTime = DateTime.Now;
string myTimeSting = myTime.ToString ( "yyyyMMddHHmm");
 
H

Hans Kesting

Ha said:
How can I convert a string like '200412240000' to a DateTime type.

DateTimeFormatInfo myDTFI = new DateTimeFormatInfo();
myDTFI.ShortDatePattern = "yyyyMMddHHmm";
DateTime dt = DateTime.Parse(pDateString, myDTFI);


Hans Kesting
 
T

Tom Porterfield

How can I convert a string like '200412240000' to a DateTime type.

DateTime date = DateTime.ParseExact("200412240000"
, "yyyyMMddHHmm"
, new DateTimeFormatInfo());
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

DateTime.ParseExact

What the trailing 4 ceros means?

Cheers,
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

I think he wants the opposite , from string to datetime

Cheers,
 
D

Dan Bass

READ the question Dan, READ the question... ;o)

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

I think he wants the opposite , from string to datetime

Cheers,
 

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


Top