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

toolStripStatusLabel3.Text = (DateTime.Now.ToString());

How do I get the value of DateTime to show two characters when it is inthe AM?

What I get in PM = 10/31/07 12:34:22 PM
What I get in AM = 10/31/07 2:34:22 AM

I need: 10/31/07 02:34:22 AM
To make my comparisons easier.

Or better yet, I want to start someting after a certain date.time and end
when another date/time is met. Any ideas how to do this wihtout complicated
string comparisons?

Oct 31 '07 #1
1 2590
CMartin,

Why not take the string and convert to a DateTime instance using the
Parse (or TryParse, if you are unsure of the format) method? You would have
a much easier time comparing the DateTime instances then.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"CMartin" <CM*****@discussions.microsoft.comwrote in message
news:E6**********************************@microsof t.com...
How do I get the value of DateTime to show two characters when it is inthe
AM?

What I get in PM = 10/31/07 12:34:22 PM
What I get in AM = 10/31/07 2:34:22 AM

I need: 10/31/07 02:34:22 AM
To make my comparisons easier.

Or better yet, I want to start someting after a certain date.time and end
when another date/time is met. Any ideas how to do this wihtout
complicated
string comparisons?

Oct 31 '07 #2

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

Similar topics

0
by: Vagabond Software | last post by:
I posted this problem earlier and now have more information. I use the DataTable Select method to get find the most recent "LastModified" date in a table of similarly named files. I then use the...
1
by: Jason Chan | last post by:
DateTime mydate = new DateTime(2006,1,1,0,0,0); string testStr = mydate.ToString("hh:mm:ss"); //return 12:00:00 mydate = new DateTime(2006,1,1,1,0,0) testStr = mydate.ToString("hh:mm:ss");...
7
by: Dylan Parry | last post by:
Hi folks, I was wondering if there is any way of formatting a date to include the ordinal characters? I've looked at the documentation for DateTime.ToString(), but no where can I find...
3
by: Sugandh Jain | last post by:
What you have told is a nice way. but this is taking hour in 12 hour format, but I want it in 24 hour format, because I have to it to generate ID's which always increase in value. How to use it in...
1
by: Marc Gravell | last post by:
Just been debugging a daylight savings glitch... something that interested me: (in a BST locale at 5:14 local time, 4:14 GMT) DateTime.Now.ToString("R") >"Mon, 26 Mar 2007 05:14:34 GMT" ...
4
by: Grant Merwitz | last post by:
Hi, I'm trying to enter the time in the following format: HH:MM:SS AM/PM e.g. 05:33:21 PM How can i achieve this from the Date Time object? DateTime.Now.ToString("?");
5
by: Nick Gilbert | last post by:
Hi, One of our servers is behaving differently to all the others when printing dates. They seem to be outputting in American format (12 hour) when the default for a UK machine should be UK...
6
by: Andy B | last post by:
I need to take the value of a textbox and format it in a more readable date. How do you do this? I tried textbox.text.tostring("date format string") but the compiler doesnt like that idea... any...
0
by: Chizl | last post by:
I think I found a bug DateTime.ToString when formatting under GMT. This took me about 15 to figure this has to be a bug in the formatting within ToString. I was adding support to allow browsers...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.