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

C# 24 hour time?

Hello,

I am trying to use tostring to convert to a 24 hour time format, but am
getting the error "No Overload for Method 'ToString'takes '1'
arguments".

The following is what I have and it seems that this should function:

NewEvent.TPDateTime =
DateTime.Parse(drCurProcess[COL_TPDATETIME].ToString("HH/mm/ss"));

Am I missing something here? Thank you very much.

DH

*** Sent via Developersdex http://www.developersdex.com ***
Mar 29 '06 #1
6 19904
Hi

Maybe try this:
System.DateTime MyDateTime = System.DateTime.Now;
MessageBox.Show(System.Convert.ToString(MyDateTime ));

"Dogmar Hoffman" wrote:
Hello,

I am trying to use tostring to convert to a 24 hour time format, but am
getting the error "No Overload for Method 'ToString'takes '1'
arguments".

The following is what I have and it seems that this should function:

NewEvent.TPDateTime =
DateTime.Parse(drCurProcess[COL_TPDATETIME].ToString("HH/mm/ss"));

Am I missing something here? Thank you very much.

DH

*** Sent via Developersdex http://www.developersdex.com ***

Mar 29 '06 #2
Dogmar Hoffman <it******@itbranch.com> wrote:
I am trying to use tostring to convert to a 24 hour time format, but am
getting the error "No Overload for Method 'ToString'takes '1'
arguments".

The following is what I have and it seems that this should function:

NewEvent.TPDateTime =
DateTime.Parse(drCurProcess[COL_TPDATETIME].ToString("HH/mm/ss"));

Am I missing something here? Thank you very much.


You're calling ToString *within* the Parse, instead of after it. You
want:

NewEvent.TPDateTime =
DateTime.Parse(drCurProcess[COL_TPDATETIME]).ToString("HH/mm/ss");

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 29 '06 #3
Thank you very much for the reply.

I have made the change, but now it says that it can not convert an obect
to a string. I do not get this error with:

NewProcess.TPDateTime =
DateTime.Parse(drCurProcess[COL_TPDATETIME].ToString());

just with:

NewProcess.TPDateTime =
DateTime.Parse(drCurProcess[COL_TPDATETIME]).ToString("HH/mm/ss");

Is there a difference in the way that C# treats ToString() for 24 hour
format? Thank you again!

DH

*** Sent via Developersdex http://www.developersdex.com ***
Mar 29 '06 #4
> Hello,

I am trying to use tostring to convert to a 24 hour time format, but am
getting the error "No Overload for Method 'ToString'takes '1'
arguments".

The following is what I have and it seems that this should function:

NewEvent.TPDateTime =
DateTime.Parse(drCurProcess[COL_TPDATETIME].ToString("HH/mm/ss"));

Am I missing something here? Thank you very much.

DH

*** Sent via Developersdex http://www.developersdex.com ***


If you are sure drCurProcess[COL_TPDATETIME] contains a valid date
(and not DbNull.Value or an invalid date - like MySql can store), then
you can cast:

NewEvent.TPDateTime = (DateTime)drCurProcess[COL_TPDATETIME];
Hans Kesting
Mar 29 '06 #5

Perfect. All is working . Thank you very much.

DH
*** Sent via Developersdex http://www.developersdex.com ***
Mar 29 '06 #6
Hi,

Out of curiosity, what is the type of TPDateTime ?
what is the type and value of drCurProcess[COL_TPDATETIME] ?

try:

NewProcess.TPDateTime = DateTime.Parse(
drCurProcess[COL_TPDATETIME].ToString() ).ToString("HH/mm/ss");
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dogmar Hoffman" <it******@itbranch.com> wrote in message
news:uw**************@TK2MSFTNGP10.phx.gbl...
Thank you very much for the reply.

I have made the change, but now it says that it can not convert an obect
to a string. I do not get this error with:

NewProcess.TPDateTime =
DateTime.Parse(drCurProcess[COL_TPDATETIME].ToString());

just with:

NewProcess.TPDateTime =
DateTime.Parse(drCurProcess[COL_TPDATETIME]).ToString("HH/mm/ss");

Is there a difference in the way that C# treats ToString() for 24 hour
format? Thank you again!

DH

*** Sent via Developersdex http://www.developersdex.com ***

Mar 29 '06 #7

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

Similar topics

5
by: marty | last post by:
As part of an assignment I need to calculate a 24 hour time by subtracting a one time from another e.g. if the user enters 1.00 as the time and 1.30 as the time to subtract the returned time is...
7
by: Robert Misiak | last post by:
Hello- I live in the US, however I'm attempting to make a product of mine more international-friendly. There are a number of instances where a calendar function of my program displays various...
2
by: spoonerstreet | last post by:
I am trying to take standard MS Time: 2/22/2006 8:56:37 AM (stored in MS Decimal Format) and convert it to the half hour of the day it occurred in: 2/22/2006 8:56:37 AM would be in the 18th...
3
by: Pieter Coucke | last post by:
Hi, For some reason, somewhere in my application 1 hour is added to my dates, depending in which time zone the application is run... Because I don't have a clue where this happens, I posted this...
5
by: Summu82 | last post by:
HI I have to convert a time in the format i have year month day hour min and seconds I need to convert this into time in seconds since 1 jan 1970 i.e the
3
by: Shawn Yates | last post by:
I have a database that I am using as a Time clock where employees can clock in and out. Is there a way to make it so that when they clock out a form would open displaying their work day hour by...
2
by: =?Utf-8?B?R2ls?= | last post by:
I have a server (Win2k3 SBS) that is a domain controller and exchange server. I failed to apply the DST patches until after the DST kicked in. I have since completed successfully the patches and...
2
by: nex85 | last post by:
hi! HOUR FROM TIME i) does anyone know how to determine which hour a time value lies in? the arrival time is in hh:mm:ss format. for e.g.: for an arrival time of 17:00:26, the correct conversion...
11
by: jonathan184 | last post by:
Hi I am trying to do a script to monitor a dir where files pass through approx every 5 mins but sometimes files may not come in for hours So the purpose of the script is to monitor by if no files...
10
ollyb303
by: ollyb303 | last post by:
Hello, Need some help with an Access 2000 query. My query is based on a table which is a log of calls to my company. I am using a date range entered by the user (Date Between And ) and...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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.