473,503 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert Dec06 to Dec 2006

Joe
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)
Nov 16 '05 #1
3 1155
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.
Nov 16 '05 #2
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

Nov 16 '05 #3
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 - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4

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

Similar topics

65
21320
by: kyle.tk | last post by:
I am trying to write a function to convert an ipv4 address that is held in the string char *ip to its long value equivalent. Here is what I have right now, but I can't seem to get it to work. ...
5
43766
by: Ray | last post by:
I have a table with some audit date and time columns. Problem is the developer who stored the data left them as DECIMAL type instead of DATE and TIME. Is there a way I can convert the DECIMAL type...
9
3664
by: Simple Simon | last post by:
Java longs are 8 bytes. I have a Java long that is coming in from the network, and that represents milliseconds since Epoch (Jan 1 1970 00:00:00). I'm having trouble understanding how to get it...
3
1738
by: Oren | last post by:
Hi, I use DateTime.Now and Serialize an object into XML field (Sql 2005). the problem is that: select CONVERT(datetime, '2006-10-09T13:54:06.9248089+02:00') ERROR: Conversion failed when...
3
14277
by: LimaCharlie | last post by:
Good Day to Everyone, Need help! I have this SQL table w/ fieldname "PayPeriod". Sample value of PayPeriod are SEP06-1, SEP06-2, OCT06-1, OCT06-2... Wherein the first 3 chars is the month, 06...
2
11983
by: kirke | last post by:
Hi, I have a datetime column named dtDateTime. its format is "Oct 27 2006 12:00:00 " I want to group by only date part of it and count my code is $sql1="SELECT ...
3
3150
by: shapper | last post by:
Hello, Could someone tell me how to convert a XML file into another XML file using a XSL file with a parameter? I created the code to do it, and it seems ok, but it is not working. Could...
10
38934
by: satishrajana | last post by:
Hi, My SQL returns a NULL in a datefield if there is no date in that field. If there is a NULL in this column, I want to replace it with spaces in my SELECT statement when I am selecting these...
4
39298
by: perryclisbee via AccessMonster.com | last post by:
I have dates of service for several people that range all over each month. ie: patient had dates of service of: 7/3/2006, 7/24/2006 and 7/25/2006. I need to create a new field via a query that...
0
7203
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
7089
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
7339
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...
1
6995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5581
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
738
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.