473,325 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

DateTime convert


How can I convert a string like '200412240000' to a DateTime type.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
7 17424
Use the ToString() method...

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

"Ha ha" <ha**@devdex.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...

How can I convert a string like '200412240000' to a DateTime type.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #2
Ha ha wrote:
How can I convert a string like '200412240000' to a DateTime type.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


DateTimeFormatInfo myDTFI = new DateTimeFormatInfo();
myDTFI.ShortDatePattern = "yyyyMMddHHmm";
DateTime dt = DateTime.Parse(pDateString, myDTFI);
Hans Kesting
Nov 16 '05 #3
Ha ha <ha**@devdex.com> wrote:
How can I convert a string like '200412240000' to a DateTime type.


I would suggest using the DateTime.ParseExact method.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4
On Thu, 23 Dec 2004 02:19:10 -0800, Ha ha wrote:
How can I convert a string like '200412240000' to a DateTime type.


DateTime date = DateTime.ParseExact("200412240000"
, "yyyyMMddHHmm"
, new DateTimeFormatInfo());
--
Tom Porterfield
Nov 16 '05 #5
Hi,

DateTime.ParseExact

What the trailing 4 ceros means?

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"Ha ha" <ha**@devdex.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...

How can I convert a string like '200412240000' to a DateTime type.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #6
Hi,

I think he wants the opposite , from string to datetime

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dan Bass" <danielbass [at] postmaster [dot] co [dot] uk> wrote in message
news:u%****************@tk2msftngp13.phx.gbl...
Use the ToString() method...

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

"Ha ha" <ha**@devdex.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...

How can I convert a string like '200412240000' to a DateTime type.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 16 '05 #7
READ the question Dan, READ the question... ;o)

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:eW**************@TK2MSFTNGP14.phx.gbl...
Hi,

I think he wants the opposite , from string to datetime

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dan Bass" <danielbass [at] postmaster [dot] co [dot] uk> wrote in message
news:u%****************@tk2msftngp13.phx.gbl...
Use the ToString() method...

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

"Ha ha" <ha**@devdex.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...

How can I convert a string like '200412240000' to a DateTime type.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Nov 16 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nikola | last post by:
Hi all, I have a problem converting datetime to integer (and than back to datetime). Depending whether the time is AM or PM, same date is converted to two different integer representations,...
16
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am...
38
by: nobody | last post by:
I know that given a FormatString and a DateTime you can use DateTime.ToString(...) to convert the DateTime to a String. My question is how can you turn that around? Given a String and a...
3
by: Mark | last post by:
Hey everybody. Is there an easy way in vb.net to convert the local time of a machine to US CST ? My machines are distributed throughout and the server is requesting we send the time of the txns...
26
by: Reny J Joseph Thuthikattu | last post by:
Hi, I have a variabe in the format of 'DD-MON-YYYY HH:MI AM' .I want to add a miniute to it.How can i do that? by manipulation i want to make '01-JUNE-2004 11:59 PM' to '02-JUNE-2004 12:00 AM'...
11
by: Tim | last post by:
Hi, I am trying to do something simple. Convert a string date to datetime but it is not working and is giving me a baffling error! System.Convert.ToDateTime("Jan 30, 2006")...
5
by: iulian.ilea | last post by:
Is correct to have a varchar field and insert dates of type dd/mm/yyyy into it? I choose this method because I have an application that runs on more than one server. So, if I used a datetime field...
7
by: groups | last post by:
This is my first foray into writing a generic method and maybe I've bitten off more than I can chew. My intent is to have a generic method that accepts a value name and that value will be...
2
by: Mike | last post by:
Hi, I have DateTime filed in db table. I'd like to search my db based on DateTime filed, actually to list all rows with particular date, for e.g. 16.11.2007... I send string to method for....
1
Manikgisl
by: Manikgisl | last post by:
But the problem is we have dates in Varchar instead Datetime While Converting Varchar To Datetime All four formats are unable to Convert ie select Convert(Datetime,'18-11-2008 2:35:19...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.