473,387 Members | 1,749 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,387 software developers and data experts.

DateTime Question?

Hi All, I am getting date in yyyyMMdd format.How do I parse it?
string s="20050302";
need to convert this to DateTime object

TIA
Nov 16 '05 #1
4 11216
Vai2000 <no****@microsoft.com> wrote:
Hi All, I am getting date in yyyyMMdd format.How do I parse it?
string s="20050302";
need to convert this to DateTime object


Use DateTime.ParseExact:

DateTime dt = DateTime.ParseExact (s, "yyyyMMdd",
CultureInfo.InvariantCulture);

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Try the DateTime.ParseExact() method.

--
Tim Wilson
..Net Compact Framework MVP

"Vai2000" <no****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi All, I am getting date in yyyyMMdd format.How do I parse it?
string s="20050302";
need to convert this to DateTime object

TIA

Nov 16 '05 #3
Thanks ya all

"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:eY**************@TK2MSFTNGP10.phx.gbl...
Try the DateTime.ParseExact() method.

--
Tim Wilson
.Net Compact Framework MVP

"Vai2000" <no****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi All, I am getting date in yyyyMMdd format.How do I parse it?
string s="20050302";
need to convert this to DateTime object

TIA


Nov 16 '05 #4
try this:

DateTimeFormatInfo myDTFI = new DateTimeFormatInfo();
myDTFI.DateSeparator = string.Empty;
myDTFI.FullDateTimePattern = mask;
string s = "20050302";
DateTime d = DateTime.ParseExact(s, myDTFI);

Nov 16 '05 #5

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

Similar topics

3
by: Grant Edwards | last post by:
Is it true that a datetime object can convert itself into a string, but not the other way around? IOW, there's no simple way to take the output from str(d) and turn it back into d? So, I tried...
6
by: Carl | last post by:
Hi, to be use with SQL server database 1- From window form textbox object From this assignement, txtTOTAL.Text="0.00m"; How do you convert back to decimal type ? How do you assign a...
8
by: Jimmie | last post by:
Hiya all, very quick question, I hope .. I have an xml dump of some old data that I need to parse and input into a new system. A couple of date fields are in there that have the following data...
3
by: Andrew S. Giles | last post by:
Hello, I am importing a flat text file, and putting it into a datagrid for display on a form. Currently the users have their dates and times seperated. I have two fields, therefore in the...
8
by: Alan Silver | last post by:
Hello, I have a custom control that displays the date and time. I currently have properties for the day, month, year, hour and minute, which have to be set separately. This is inefficient. I...
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'...
9
by: Phil B | last post by:
I am having a problem with a datetime from a web services provider The provider is sending the following SOAP response <?xml version="1.0" encoding="utf-8"?> <soap:Envelope...
4
by: Philippe Martin | last post by:
Hi, I need to get the date and time under Windows and Linux but need the information visible to the user (cannot find my words) not the sytem information (ex: a PC setup on greenwich but the...
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...
0
by: maolimix | last post by:
Hi to all, I have a trouble with datetime...now I explain.. I must to store to a C# variable the values from a "Datetime column" of Sql Server 2005. I tried 3 methods ...in the first two I never...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.