473,406 Members | 2,259 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,406 software developers and data experts.

parse dates

I need to be able to parse both of these dates with the same method, and
return them as a DateTime object. Is there any methods that would do this
blindly or do I need to provide the format?

Feb 25 23:11

Dec 1 2002
Nov 13 '05 #1
7 6603
Hi,

You might try DateTime.Parse using InvariantCulture:

DateTime dt = DateTime.Parse(yourdate,
System.Globalization.CultureInfo.InvariantCulture)

Miha

"memememe" <[rem]casolorz[rem]@hot[rem]mail.com> wrote in message
news:TC*******************@news1.central.cox.net.. .
I need to be able to parse both of these dates with the same method, and
return them as a DateTime object. Is there any methods that would do this
blindly or do I need to provide the format?

Feb 25 23:11

Dec 1 2002

Nov 13 '05 #2
thanks for the idea, but it didnt work :-(
im actually starting to think that it might be a good idea to try catch it
with one format using parseexact and if it fails, I try the other format, of
course that only works if those are the two only possible formats, which I
am not sure they are.
"Miha Markic" <mi***@spin.NO.SPAM.si> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi,

You might try DateTime.Parse using InvariantCulture:

DateTime dt = DateTime.Parse(yourdate,
System.Globalization.CultureInfo.InvariantCulture)

Miha

"memememe" <[rem]casolorz[rem]@hot[rem]mail.com> wrote in message
news:TC*******************@news1.central.cox.net.. .
I need to be able to parse both of these dates with the same method, and
return them as a DateTime object. Is there any methods that would do this blindly or do I need to provide the format?

Feb 25 23:11

Dec 1 2002


Nov 13 '05 #3
> You might try DateTime.Parse using InvariantCulture:
Why with InvariantCulture?

Mihai
Nov 13 '05 #4
It never changes (it is not regional setting dependent) - it is fixed and
you are certain what you'll get.

Miha

"Mihai N." <nm*********@yahoo.com> wrote in message
news:Xn*******************@204.127.204.17...
You might try DateTime.Parse using InvariantCulture:

Why with InvariantCulture?

Mihai

Nov 13 '05 #5
> It never changes (it is not regional setting dependent) - it is fixed and
you are certain what you'll get. I know this. I was just not my understanding that he wanted something
regional setting independent.
I think he was just trying to solve his problem in English, without thinking
what happens if in 2 months the marketing guys will ask for German.
I need to be able to parse both of these dates with the same method, and
return them as a DateTime object. Is there any methods that would do this
blindly or do I need to provide the format?


My normal answer would be: use DateTime.Parse.
And depending on what you need, you may use a CultureInfo or not,
invariant or not.

Mihai
Nov 15 '05 #6
> It never changes (it is not regional setting dependent) - it is fixed and
you are certain what you'll get. I know this. I was just not my understanding that he wanted something
regional setting independent.
I think he was just trying to solve his problem in English, without thinking
what happens if in 2 months the marketing guys will ask for German.
I need to be able to parse both of these dates with the same method, and
return them as a DateTime object. Is there any methods that would do this
blindly or do I need to provide the format?


My normal answer would be: use DateTime.Parse.
And depending on what you need, you may use a CultureInfo or not,
invariant or not.

Mihai
Nov 15 '05 #7

"Mihai N." <nm*********@yahoo.com> wrote in message
news:Xn*******************@204.127.204.17...
It never changes (it is not regional setting dependent) - it is fixed and you are certain what you'll get. I know this. I was just not my understanding that he wanted something
regional setting independent.
I think he was just trying to solve his problem in English, without

thinking what happens if in 2 months the marketing guys will ask for German.
I need to be able to parse both of these dates with the same method, and
return them as a DateTime object. Is there any methods that would do this blindly or do I need to provide the format?


My normal answer would be: use DateTime.Parse.
And depending on what you need, you may use a CultureInfo or not,
invariant or not.

Mihai


I actually solved the problem we had by first calling parse, if that failed,
I would call parseExact and I would give it a formats array tht contained
what we consider valid formats so far. The reason I didnt do just the
parseExact call is because there is a lot of possible date formats we might
get that might not be on our formats array but maybe the parse method would
understand.
Nov 15 '05 #8

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

Similar topics

7
by: Nova's Taylor | last post by:
Hi folks, I am a newbie to Python and am hoping that someone can get me started on a log parser that I am trying to write. The log is an ASCII file that contains a process identifier (PID),...
4
by: Paul Beckett | last post by:
Does anyone know how to prevent an error when using DateTime.Parse? I am using it to format the display of dates in my database. However, some dates are empty and so I get an error when I try to...
4
by: Matteo | last post by:
Hy everybody. I'm not a html writer, but a sysadmin who's trying to help a user able to compile an online form with IE but not with Mozilla (Moz1.6, Ns7.1, Firefox 0.8+) due to a javascript date...
14
by: Jon Davis | last post by:
I have put my users through so much crap with this bug it is an absolute shame. I have a product that reads/writes RSS 2.0 documents, among other things. The RSS 2.0 spec mandates an en-US style...
0
by: Andy Fish | last post by:
Hello, I'm trying to parse dates in ISO 8601 format. I tried this: DateTime.ParseExact(inputValue, "s", CultureInfo.InvariantCulture) But this only works with one specific format. Is there...
9
by: RMC | last post by:
Hello, I'm looking for a way to parse/format a memo field within a report. The Access 2000 database (application) has an equipment table that holds a memo field. Within the report, the memo...
29
by: gs | last post by:
let say I have to deal with various date format and I am give format string from one of the following dd/mm/yyyy mm/dd/yyyy dd/mmm/yyyy mmm/dd/yyyy dd/mm/yy mm/dd/yy dd/mmm/yy mmm/dd/yy
2
by: Jeremy | last post by:
I can't get dates to parse with any accuracy. I have a date like this, for example: Fri May 25 07:58:46 GMT 2007 I am using a SimpleDateFormat with a format string of: EEE MMM dd HH:MM:SS...
1
by: =?Utf-8?B?YXZucmFv?= | last post by:
We have a web service that gets data in xml format. In that Xml data, we parse few date fields that are in this format <data datefield="12/26/2008" timefield="16:33:45" ...> we parse it into a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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
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...
0
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...
0
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...

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.