473,507 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date time

Why i cann't convert date to DateTime :
System.DateTime dd= Convert.ToDateTime("27/09/2003");

How to do that , tjis one thowes an exception .

I can't find a Date class
Nov 15 '05 #1
2 1249
Dates of that format are ambiguous. It's probably trying to parse this as
MM/dd/yyyy. Clearly this specific date is dd/MM/yyyy but the parser doesn't
try to figure that out. You can use DateTime.ParseExact, e.g.

DateTime dd = DateTime.ParseExact("27/09/2003", "dd/MM/yyyy");

See the documentation for DateTime.Parse to see some more flexible examples
of how to do this without explicitly specifying the format.
"Yosi" <yo*******@hotmail.com> wrote in message
news:11****************************@phx.gbl...
Why i cann't convert date to DateTime :
System.DateTime dd= Convert.ToDateTime("27/09/2003");

How to do that , tjis one thowes an exception .

I can't find a Date class

Nov 15 '05 #2
DateTime dd = DateTime.ParseExact
("27/09/2003", "dd/MM/yyyy");

I still get an error :
"(939): No overload for method 'ParseExact' takes '2'
arguments"

-----Original Message-----
Dates of that format are ambiguous. It's probably trying to parse this asMM/dd/yyyy. Clearly this specific date is dd/MM/yyyy but the parser doesn'ttry to figure that out. You can use DateTime.ParseExact, e.g.
DateTime dd = DateTime.ParseExact ("27/09/2003", "dd/MM/yyyy");
See the documentation for DateTime.Parse to see some more flexible examplesof how to do this without explicitly specifying the format.

"Yosi" <yo*******@hotmail.com> wrote in message
news:11****************************@phx.gbl...
Why i cann't convert date to DateTime :
System.DateTime dd= Convert.ToDateTime("27/09/2003");

How to do that , tjis one thowes an exception .

I can't find a Date class

.

Nov 15 '05 #3

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

Similar topics

2
5200
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
15
18861
by: Khurram | last post by:
I have a problem while inserting time value in the datetime Field. I want to Insert only time value in this format (08:15:39) into the SQL Date time Field. I tried to many ways, I can extract...
13
16128
by: maflatoun | last post by:
Hi, I have the following function to convert UTC time to Local time. It works perfect for GMT- (Minus) time zones however it provides incorrect results for GMT+(Plus) time zones? // Format to...
12
29422
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
6
12524
by: Luvin lunch | last post by:
Hi, I'm new to access and am very wary of dates as I have limited experience in their manipulation and I know if they're not done properly things can turn ugly quickly. I would like to use a...
3
3274
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when...
3
12864
by: colleen1980 | last post by:
Hi: Data in my table is in that format. How to i separate date with time. 11/9/2006 10:10:46 AM Thank You.
6
3926
by: Geoff Cox | last post by:
Hello, at the moment I can add the combined date and time into MySQL using php $dt1 = date("Y-m-d H:i:s"); is it possible to add the date and time separately? I thought it might be
0
16475
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any...
4
32941
by: ahmurad | last post by:
Dear Brothers, I am struggling the following four Date-Time type values which were inputted into MYSQL database in different tables. As MYSQL Default Time Format: YYYY-MM-DD HH:MM:SS, So I used...
0
7111
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
7319
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,...
1
7031
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7485
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5042
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1542
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.