473,387 Members | 1,548 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.

converting string to date

hi to all i need to convert string to date. it shows invalid string format for parsing
here is my code:

string s="13/07/07" //in dd/mm/yy format

DateTime d=DateTime.Parse(s) //actually system time is in mm/dd/yyyy format

but this statement shows an error"String was not reconized as a valid Datetime"
what i need to do? do i need to rearrange the string
Mar 13 '08 #1
2 1237
balame2004
142 100+
Hi,

Yes, you have to rearrange the string in the format "MM/DD/YYYY".


Balaji
Mar 13 '08 #2
Dear Write down the following Code...
First add name space Globalisation using

using System.Globalization;

then to convert given string(31/12/2008) to a date write down following
two line code.

CultureInfo culture = new CultureInfo("en-GB");

DateTime dt = Convert.ToDateTime("31/12/2008",culture);

Now 31/12/2008 which one pass a string now convert to date
but this date is in mm/dd/yyyy format not in dd/mm/yyyy format.

I hope this is useful to u...

Bye.....Take Care.....Enjoy Coding
Mar 13 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Mika M | last post by:
Is there better way to convert integer type date into DateTime type date as doing like code below? Dim intDate As Integer = 20051019 Dim dte As DateTime = New DateTime( _...
9
by: Alok yadav | last post by:
i am using a webservice in which a method is serach. i use this method which accept a argument of date type in dd/MM/yyyy formate. i have a textbox which accept the date from the user, when i...
6
by: marc | last post by:
hi im trying to convert Date() into a unix timestamp so i can stick the result into a mysql db, please help!
2
by: Brian Parker | last post by:
I am beginning to work with VB2005.NET and I'm getting some problems with string formatting converting an application from VB6. VB6 code:- sTradeDate = Format(pArray(4,i Record), "mmddyy") ...
3
by: Jef Driesen | last post by:
How can I convert a date string to a number (e.g. a time_t value or a tm struct)? I know about the strptime function, but then I have to know the format string. And that is a problem. I'm trying...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.