strange date-time format

  • Thread starter Thread starter Pawel Janik
  • Start date Start date
P

Pawel Janik

Hello...

I have the following problem. I have date in ddMMyyHHmmss format.
Is there some Parse(String format) method, because i cannot find goot
parameters for DateTime.Parse(....)?
 
Pawel Janik said:
I have the following problem. I have date in ddMMyyHHmmss format.
Is there some Parse(String format) method, because i cannot find goot
parameters for DateTime.Parse(....)?

I prefer ParseExact to Parse for this kind of thing - you need
something like:

DateTime x = DateTime.ParseExact
(value, "ddMMyyyy", CultureInfo.InvariantCulture.DateTimeFormat);

Note that which CultureInfo you wish to use will depend on exactly
where you're getting the data from. (Admittedly with the patterns we're
talking about it's unlikely to make much difference as far as I can
see, but with other patterns it would.)
 
Jon said:
I prefer ParseExact to Parse for this kind of thing - you need
something like:

DateTime x = DateTime.ParseExact
(value, "ddMMyyyy", CultureInfo.InvariantCulture.DateTimeFormat);

Note that which CultureInfo you wish to use will depend on exactly
where you're getting the data from. (Admittedly with the patterns
we're talking about it's unlikely to make much difference as far as I
can see, but with other patterns it would.)

Thanks a lot. It works perfectly!

Pawel Janik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top