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

DateTime seems like a NightMare

Hi All

I am really having problems with the DateTime class.
Please can someone tell me how to pass a simple string
like "26/05/2003" or "2003/05/26" etc into a DateTime
class. When I read the help, I am seeing things Like
Cultureinfo classes, IFormatProvider, Calendar Classes, I
don't know whats what, please can someone explain all
this for me, or point me in the right direction. As
you've probably guessed, I am new to C#, so I'm finding
it a bit difficult to grasp some of these concepts. I
don't see why I cant just pass the string and tell the
class I want it formatted like "dd/mm/yyy"

Any help is much appreciated
TIA
Kevin
Nov 15 '05 #1
1 1148
Kevin <an*******@discussions.microsoft.com> wrote:
I am really having problems with the DateTime class.
Please can someone tell me how to pass a simple string
like "26/05/2003" or "2003/05/26" etc into a DateTime
class.
Use DateTime.ParseExact with the IFormatProvider being
CultureInfo.InvariantCulture or CultureInfo.CurrentCulture
I don't see why I cant just pass the string and tell the
class I want it formatted like "dd/mm/yyy"


And you can - but the framework gives good infrastructure to allow for
culture-sensitive settings.

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

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

Similar topics

14
by: Paul Moore | last post by:
I was just writing some code which did date/time manipulations, and I found that the Python 2.3 datetime module does not supply a number of fairly basic functions. I understand the reasoning (the...
4
by: John Hunter | last post by:
>>> from datetime import date >>> dt = date(1005,1,1) >>> print dt.strftime('%Y') Traceback (most recent call last): File "<stdin>", line 1, in ? ValueError: year=1005 is before 1900; the...
6
by: Terry Hancock | last post by:
What do you do when a date or time is incompletely specified? ISTM, that as it is, there is no formal way to store this --- you have to guess, and there's no way to indicate that the guess is...
3
by: Chris Malone | last post by:
I'm trying to convert into friendly format the "LastModified" property of an object returned via WMI from remote servers. Every attempt to manipulate that using DateTime has bombed with "specified...
11
by: Cor Ligthert | last post by:
Hello everybody, Jay and Herfried are telling me every time when I use CDate that using the datetime.parseexact is always the best way to do String to datetime conversions. They don't tell why...
5
by: rs | last post by:
I have a table with a timestamp field which contains the date and time. ie. 9/13/2004 9:10:00 AM. I would like to split this field into 2 fields, one with just the DATE portion ie 9/13/2004 and...
3
by: Zachary Turner | last post by:
Hello, I have a situation where I would like to perform custom serialization and deserialization of an existing .NET framework object (specifically, System.DateTime). Is there a common paradigm...
5
by: robtyketto | last post by:
Greetings, I have an issue with my datetime picker where its not active until I select another field on my form. Any field on the form. I have tried to manually setfoucus and give values...
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...
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...
1
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.