473,396 Members | 2,011 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,396 software developers and data experts.

toDate conversions

can I convert a date string like 20031231105718
which is in format yyyymmddhhmmss into a normal date string?

can I say someting like date format yyyymmddhh:24mmss
then make that string a date and then convert?

thanks a bunch
Nov 15 '05 #1
2 11519
Sure you can convert the string into DateTime by specifing the expected
format, then convert to any format you want

Here is a small example, hope it helps!
string strMyDateTime = "20031231105718";

System.IFormatProvider format =

new System.Globalization.CultureInfo("en-US", true);
string expectedformat = "yyyyMMddHHmmss";

System.DateTime myDateTime =

System.DateTime.ParseExact(strMyDateTime,

expectedformat,

format,

System.Globalization.

DateTimeStyles.AllowWhiteSpaces);

Console.WriteLine(myDateTime.ToString () );
"bios" <ku*****@yahoo.com> wrote in message
news:d8**************************@posting.google.c om...
can I convert a date string like 20031231105718
which is in format yyyymmddhhmmss into a normal date string?

can I say someting like date format yyyymmddhh:24mmss
then make that string a date and then convert?

thanks a bunch

Nov 15 '05 #2
Thanks. Code works nicely.
:)
"jennyq" <je**********@yahoo.com> wrote in message news:<ej*************@tk2msftngp13.phx.gbl>...
Sure you can convert the string into DateTime by specifing the expected
format, then convert to any format you want

Here is a small example, hope it helps!
string strMyDateTime = "20031231105718";

System.IFormatProvider format =

new System.Globalization.CultureInfo("en-US", true);
string expectedformat = "yyyyMMddHHmmss";

System.DateTime myDateTime =

System.DateTime.ParseExact(strMyDateTime,

expectedformat,

format,

System.Globalization.

DateTimeStyles.AllowWhiteSpaces);

Console.WriteLine(myDateTime.ToString () );
"bios" <ku*****@yahoo.com> wrote in message
news:d8**************************@posting.google.c om...
can I convert a date string like 20031231105718
which is in format yyyymmddhhmmss into a normal date string?

can I say someting like date format yyyymmddhh:24mmss
then make that string a date and then convert?

thanks a bunch

Nov 15 '05 #3

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

Similar topics

3
by: Reneé | last post by:
I wanted to know the order of implicit conversions and which sort of values allow them. From searching around in books and the archive of this mailing list, it seems to be that only numbers are...
15
by: buda | last post by:
Let me see if I got this :) 1. I know the rules for type conversions in arithmetic expressions 2. I know that an implicit type conversion is done at assignment, so float x = 1.23; int t = (int)...
10
by: vb | last post by:
Hi all, I am a newbie in C and i want to know what all pointer conversions are "legal" according to ANSI C standard. For Example, int* to char*, some_struct* to char* and so on .. According to...
4
by: O. Zimmermann | last post by:
Hi all, A variable with an enumerated type can be set with a value from any other generic "enum" type in the program, or with an integer value, without notice to the user, neither at compilation...
31
by: Michael C | last post by:
If a class inherits from another class, say Form inherits from control, then I can assign the Form to a variable of type Control without needing an explicit conversion, eg Form1 f = new Form1();...
2
by: Brian Henry | last post by:
is there info about data type conversions between access to ado.net? I have tried a lot of the ones that say oledb data types should work for and get a lot of "data type mismatch" errors using...
36
by: Chad Z. Hower aka Kudzu | last post by:
I have an implicit conversion set up in an assembly from a Stream to something else. In C#, it works. In VB it does not. Does VB support implicit conversions? And if so any idea why it would work...
5
by: Daz | last post by:
Hi everyone! I am very new to casting and converting, so much in fact then when I think I have it figured out, something proves me wrong. I was wondering if there is any logic in 'what types can...
2
by: adsci | last post by:
Hello! Im posting this to c.l.c++ AND win32 because i dont know if this is a MS Compiler Issue or not. here we go: <code> class MyCString
3
by: Wayne | last post by:
Are user-defined conversions chosen at compile time, or are there ways to make sure that they are chosen at run-time, based on the actual type of the object? Here is a simplified example of what...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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,...
0
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...
0
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,...

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.