PC Review


Reply
Thread Tools Rate Thread

Convert Dec06 to Dec 2006

 
 
Joe
Guest
Posts: n/a
 
      11th Feb 2005
I can't seem to get this to work. Everything I try always seems to convert
it to Dec 06 2005.

I tried using DateTimeFormatInfo and setting YearMonth = "MMYY"
and then doing DateTime.Parse(mydate, cultureinfo)


 
Reply With Quote
 
 
 
 
Tim Jarvis
Guest
Posts: n/a
 
      12th Feb 2005
Joe wrote:

> I can't seem to get this to work. Everything I try always seems to
> convert it to Dec 06 2005.
>
> I tried using DateTimeFormatInfo and setting YearMonth = "MMYY"
> and then doing DateTime.Parse(mydate, cultureinfo)


I suppose the issue is that it's not a complete date without the day
portion. Any parsing routine would have to make a guess at what you
want for the day i.e. start of month or end of month.

Cheers Tim.
 
Reply With Quote
 
Instant Baja
Guest
Posts: n/a
 
      12th Feb 2005
Joe wrote:

> I can't seem to get this to work. Everything I try always seems to convert
> it to Dec 06 2005.


So then just take the .Month and .Year properties and add them together.

>
> I tried using DateTimeFormatInfo and setting YearMonth = "MMYY"
> and then doing DateTime.Parse(mydate, cultureinfo)


--
Texeme
http://texeme.com

 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      12th Feb 2005
Joe <J_no_spam@_no_spam_Fishinbrain.com> wrote:
> I can't seem to get this to work. Everything I try always seems to convert
> it to Dec 06 2005.
>
> I tried using DateTimeFormatInfo and setting YearMonth = "MMYY"
> and then doing DateTime.Parse(mydate, cultureinfo)


Use DateTime.ParseExact (myDate, "MMMyy", cultureInfo);

where cultureInfo is the relevant culture (or null to use the current
culture). You don't need to change anything in any actual cultures.

The real problem was that your format specifier was wrong though - you
need MMM for text, rather than MM (which would expect 01-12).

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert 1006 to date (01/10/2006) =?Utf-8?B?TWFheA==?= Microsoft Excel Programming 5 12th Mar 2007 05:38 PM
Convert 2006 calendar to 2007 =?Utf-8?B?UmF5RnJ5ZUBCbGFja1RpZUZ1bmRpbmcuY29t?= Microsoft Word Document Management 1 8th Jan 2007 04:30 PM
Convert 10/4/2006 to Oct 4 =?Utf-8?B?SmFtYnJ1aW5z?= Microsoft Excel Misc 3 9th Aug 2006 05:58 PM
Convert date text (not field)? e.g. from 5/7/06 to May 7, 2006 =?Utf-8?B?S2ltYmVybHlXUA==?= Microsoft Word Document Management 4 8th May 2006 10:18 PM
mail merge-convert 3/4/06 into March 4, 2006 =?Utf-8?B?ZGlyb3M=?= Microsoft Access External Data 4 5th Mar 2006 07:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:34 PM.