473,322 Members | 1,494 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,322 software developers and data experts.

datetime convert experts...help wanted

I have a string "05142000" i want it converted to a date.

Any good clean ways of doing this without reverting to string manipulation?

I have tried
mydate = Date.ParseExact("05142000", "ddMMyyyy", Nothing) but it complains
about "string is not supported in calendar
System.Globalization.GregorianCalendar"

any ideas?
thx

Jun 1 '06 #1
2 1346
Hi Dave,

To avoid parsing the string and creating a date from the components (pretty
easy), you might have to create a custom culture that uses that string to
represent a date. Then you'd have to create a custom DateTimeFormatInfo to
apply to it.

Sounds like a lot of trouble compared with pulling off 2, 2 and 4 characters
from the existing string.

Ken
"dave" <da**@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
I have a string "05142000" i want it converted to a date.

Any good clean ways of doing this without reverting to string
manipulation?

I have tried
mydate = Date.ParseExact("05142000", "ddMMyyyy", Nothing) but it
complains
about "string is not supported in calendar
System.Globalization.GregorianCalendar"

any ideas?
thx

Jun 2 '06 #2

"dave" <da**@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
I have a string "05142000" i want it converted to a date.

Any good clean ways of doing this without reverting to string
manipulation?

I have tried
mydate = Date.ParseExact("05142000", "ddMMyyyy", Nothing) but it
complains
about "string is not supported in calendar
System.Globalization.GregorianCalendar"


Well it would do...take a step back and look at your code. You're telling it
to make a DateTime variable where the day part is 05, the month part is 14
and the year part is 2000. Change the second argument to "MMddyyyy" and you
should be fine).
Jun 2 '06 #3

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

Similar topics

4
by: Max M | last post by:
# -*- coding: latin-1 -*- """ I am currently using the datetime package, but I find that the design is oddly asymmetric. I would like to know why. Or perhaps I have misunderstood how it...
16
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am...
3
by: Bill | last post by:
Hi I am trying to get a date range in c#. I can get the one range by date1 = DateTime.Now(); But if I wanted to go back say 5 days how do I go about calculating the date for that. I was...
2
by: Tronex | last post by:
Hi there, I am desperate and need help on this from someone who actually knows what he does... cuz I certainly don't ;-) This is the situation: I have an ASP.NET web application (written in...
38
by: nobody | last post by:
I know that given a FormatString and a DateTime you can use DateTime.ToString(...) to convert the DateTime to a String. My question is how can you turn that around? Given a String and a...
11
by: Tim | last post by:
Hi, I am trying to do something simple. Convert a string date to datetime but it is not working and is giving me a baffling error! System.Convert.ToDateTime("Jan 30, 2006")...
4
by: tshad | last post by:
Is there any difference between convert.ToDateTime and System.DateTime.Parse? I am using them both and they seem the same. Is one better to use than another? Thanks, Tom
5
by: iulian.ilea | last post by:
Is correct to have a varchar field and insert dates of type dd/mm/yyyy into it? I choose this method because I have an application that runs on more than one server. So, if I used a datetime field...
7
by: groups | last post by:
This is my first foray into writing a generic method and maybe I've bitten off more than I can chew. My intent is to have a generic method that accepts a value name and that value will be...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.