473,399 Members | 3,038 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,399 software developers and data experts.

Formatting a datetime

I need to take System.DateTime.Now and have the resulting text be in the
following format:
yyyyMMddhh24mmsss
I am using System.Convert.ToString(System.DateTime.Now), but I need to
format it correctly, what is the easiest way to accomplish this?
May 25 '06 #1
3 9847
Eric,

I assume by

yyyyMMddhh24mmsss

What you really mean is four digit year, two digit month, two digit day,
two digit hour (in military time), two digit minute, two digit second (I
dont know what the third s is for). All digits will have a trailing zero,
if necessary.

Your pattern is:

yyyyMMddHHmmss

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Eric Stott" <eric@stottcreations_nospam.com> wrote in message
news:e9**************@TK2MSFTNGP04.phx.gbl...
I need to take System.DateTime.Now and have the resulting text be in the
following format:
yyyyMMddhh24mmsss
I am using System.Convert.ToString(System.DateTime.Now), but I need to
format it correctly, what is the easiest way to accomplish this?

May 25 '06 #2
Yes that is the pattern.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:OY**************@TK2MSFTNGP04.phx.gbl...
Eric,

I assume by

yyyyMMddhh24mmsss

What you really mean is four digit year, two digit month, two digit
day, two digit hour (in military time), two digit minute, two digit second
(I dont know what the third s is for). All digits will have a trailing
zero, if necessary.

Your pattern is:

yyyyMMddHHmmss

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Eric Stott" <eric@stottcreations_nospam.com> wrote in message
news:e9**************@TK2MSFTNGP04.phx.gbl...
I need to take System.DateTime.Now and have the resulting text be in the
following format:
yyyyMMddhh24mmsss
I am using System.Convert.ToString(System.DateTime.Now), but I need to
format it correctly, what is the easiest way to accomplish this?


May 25 '06 #3
I guess Nicholas meant to say you have to use:

System.DateTime.Now.ToString("yyyyMMddHHmmss") ;

/LM
"Eric Stott" <eric@stottcreations_nospam.com> wrote in message
news:OS**************@TK2MSFTNGP03.phx.gbl...
Yes that is the pattern.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:OY**************@TK2MSFTNGP04.phx.gbl...
Eric,

I assume by

yyyyMMddhh24mmsss

What you really mean is four digit year, two digit month, two digit
day, two digit hour (in military time), two digit minute, two digit
second (I dont know what the third s is for). All digits will have a
trailing zero, if necessary.

Your pattern is:

yyyyMMddHHmmss

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Eric Stott" <eric@stottcreations_nospam.com> wrote in message
news:e9**************@TK2MSFTNGP04.phx.gbl...
I need to take System.DateTime.Now and have the resulting text be in the
following format:
yyyyMMddhh24mmsss
I am using System.Convert.ToString(System.DateTime.Now), but I need to
format it correctly, what is the easiest way to accomplish this?



May 26 '06 #4

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

Similar topics

8
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 $...
1
by: McGiv | last post by:
Hi, I'm trying to serialise some objects and I've can't get the built in serialisation to output exactly what I want. For the moment I'm implementing the IXmlSerializable interface and doing it...
1
by: Lauchlan M | last post by:
Hi In an ASP.NET application, I am doing the following (dtrData is a data reader that has been loaded with data already): if (dtrData.Read()) { lblEDPresentationTime.Text = (DateTime)...
4
by: darrel | last post by:
I'm binding fileinformation to a repeater and attempting to display the 'lastWriteTime' property as a formatted date. This: <%# DataBinder.Eval(Container.DataItem, "LastWriteTime" %> Gives...
2
by: Mark | last post by:
I am running into a weird problem. I am using the following code: String.Format("{0:0}:{1:00}:{2:00}", Hours.ToString, Minutes.ToString, Seconds.ToString) Just say seconds is set to 1, it...
2
by: TJ | last post by:
Why doesn't this work?\ string _s = String.Format("{0:M/d/yyyy}","5/20/2005 12:00:00 AM); Response.Write(_s); It kicks back the full date and time...I just want the date to show and not the...
4
by: Ken Wigle | last post by:
All, I would be very grateful for any help on this question. I have an application in asp.net 2.0 where I dynamically create a datatable and then bind that to a gridview. Unfortunately, the...
7
by: sherifffruitfly | last post by:
Hi, God I hate datetime string formatting... How do I get a string of the form "04-Oct-2006", for example, from a DateTime object? Thanks a jillion, cdj
1
by: Untitled | last post by:
I have an application that stores all DateTime inforamtion in UTC. However, this application will be accessed from arround the world. I would like my users to be able to specify their prefered...
3
by: Tim | last post by:
Folks, I'm trying to format a print string so that it reports progress whilst processing a looping structure with a date time stamp appended to the end of the string. This started out life as a...
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
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
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
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...
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,...
0
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...

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.