473,671 Members | 2,229 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parsing string dates into DateTime

Hi,

Say you are working with a CSV file generated by a legacy mainframe which
stores dates in the format 'ddMMMyy' e.g. ,16JUN05,

Extracting the individual date parts is easy enough, but is there a "neat"
way of converting the string 'JUN' into the integer 6. Obviously it would be
easy enough to write a function for this, but is there a simpler way, say,
with int.Parse or something similar.

Just curious... :-)

Mark
Nov 17 '05 #1
2 1443
"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in
news:u$******** ******@TK2MSFTN GP15.phx.gbl:
Say you are working with a CSV file generated by a legacy mainframe
which stores dates in the format 'ddMMMyy' e.g. ,16JUN05,

Extracting the individual date parts is easy enough, but is there a
"neat" way of converting the string 'JUN' into the integer 6.
Obviously it would be easy enough to write a function for this, but is
there a simpler way, say, with int.Parse or something similar.

Just curious... :-)


DateTime.Parse
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"

Make your ASP.NET applications run faster
http://www.atozed.com/IntraWeb/
Nov 17 '05 #2
"Chad Z. Hower aka Kudzu" <cp**@hower.org > wrote in message
news:Xn******** *************** **@127.0.0.1...
DateTime.Parse


Thanks.
Nov 17 '05 #3

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

Similar topics

8
9437
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $ Last-Modified: $Date: 2003/10/28 19:48:44 $ Author: A.M. Kuchling <amk@amk.ca> Status: Draft Type: Standards Track
9
2756
by: Thomas W | last post by:
I'm developing a web-application where the user sometimes has to enter dates in plain text, allthough a format may be provided to give clues. On the server side this piece of text has to be parsed into a datetime python-object. Does anybody have any pointers on this? Besides the actual parsing, my main concern is the different locale date formats and how to be able to parse those strange us-like "month/day/year" compared to the clever...
6
1948
by: Kalle Anke | last post by:
I want to parse a date string, for example '2005-09-23', and since I haven't done this before I would like to ask what is the best way to do it. I've looked around and the dateutil seems to be what most people use, but unfortunately I only get an empty file when I try to download it. I also tried the standard modules and ended up with this import datetime from time import strptime
38
807
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 FormatString, how can you convert the String back to a DateTime? DateTime.Parse(...) doesn't use the FormatString. Now admitedly, if the format string is just "MM", it can't be done. But if the format string is "yyyyMMdd", or "ddMMMyyyy hhmmsst", it...
50
4928
by: z. f. | last post by:
HI, i have string in format dd/mm/yyyyy hh:mm:ss and giving this as an input to DateTime.Parse gives a string was not recognized as a valid date time format string error. how do i make the parse method to accept formating that i need. if i do console.writeLine DateTime.Now.ToString it gives the format: YYYY-MM-DD HH:MM:SS TIA, Z.
6
4315
by: Tim N. van der Leeuw | last post by:
Hi, I want to parse strings containing date-time, which look like the following: "Mon Dec 19 11:06:12:333 CET 2005" That's a problem for strptime it seems, b/c I cannot find any format-spec for the milliseconds-part in here. (I'm also not sure about the validity of the tz part, but ...)
0
1134
by: Uncle Leo | last post by:
I created an OleDbDataAdapter with the wizard in Visual Studio 2003. It created a dataset, connectionstring etc. for me to work with. It also created a .xsd file where one of the columns type is set to date. My program is being used in many different countries, and many different local settings. Some time ago a user from Turkey contacted me saying my program crashed on his system with the following error code: System.ArgumentException:...
6
3381
by: i_robot73 | last post by:
I have a file, containing hex values for dates (MMDDYYYY)<status code><??such as: 303530313230303102003035303232303031020030353033323030310200303530343230303102003035303732303031020030353038323030310200 breaking that down: 30353031323030310200 30353032323030310200 30353033323030310200
0
8476
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8670
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7437
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6229
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5696
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4225
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2812
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1809
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.