this fails.
string sdt="20040330 930";
string[] fmts ={"yyyyMMdd Hmm"};
DateTime date = DateTime.ParseExact(sdt, fmts,
DateTimeFormatInfo.InvariantInfo,
DateTimeStyles.AllowLeadingWhite|DateTimeStyles.AllowTrailingWhite);
any workarounds? urgent, please!!!
TIA
> string sdt="20040330 930";
>
> string[] fmts ={"yyyyMMdd Hmm"};
>
> any workarounds? urgent, please!!!
Why not use an regular expression !?
^(\d\d\d\d)(\d\d\)(\d\d)\s+(\d)(\d\d)$
Now you have
Match.Groups[1] = yyyy
Match.Groups[2] = MM
Match.Groups[3] = dd
Match.Groups[4] = H
Match.Groups[5] = mm

Signature
Greetings
Jochen
Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp
Do you need daily reports from your server?
http://sourceforge.net/projects/srvreport/
Jochen Kalmbach - 30 Mar 2004 21:30 GMT
>> string sdt="20040330 930";
>>
[quoted text clipped - 5 lines]
>
> ^(\d\d\d\d)(\d\d\)(\d\d)\s+(\d)(\d\d)$
Or even better:
^(\d\d\d\d)(\d\d\)(\d\d)\s+(\d?\d)(\d\d)$
So it will also match HH

Signature
Greetings
Jochen
Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp
Do you need daily reports from your server?
http://sourceforge.net/projects/srvreport/
> this fails.
> string sdt="20040330 930";
[quoted text clipped - 7 lines]
>
> any workarounds? urgent, please!!!
The problem (I believe) is that it's greedily taking the hours (as 93).
If you separate the hours from the minutes, or use a 24 hour format, it
should be okay. Is that a possible solution for you?

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Katy King - 31 Mar 2004 01:33 GMT
> > this fails.
> > string sdt="20040330 930";
[quoted text clipped - 7 lines]
> >
> > any workarounds? urgent, please!!!
> The problem (I believe) is that it's greedily taking the hours (as 93).
> If you separate the hours from the minutes, or use a 24 hour format, it
> should be okay. Is that a possible solution for you?
Indeed. Either of the suggestions above (either ParseExact("20040330
0930", "yyyyMMdd Hmm")
or ParseExact("20040330 9 30", "yyyyMMdd H mm")) should succeed.
I have filed a bug on the issue.
Katy King
jai hanuman - 31 Mar 2004 21:33 GMT
> > this fails.
> > string sdt="20040330 930";
[quoted text clipped - 11 lines]
> If you separate the hours from the minutes, or use a 24 hour format, it
> should be okay. Is that a possible solution for you?
thanks, i had to hack it and add the 0 before the hour before parsing it.