PC Review


Reply
Thread Tools Rate Thread

DateTime + representing only the time

 
 
DaTurk
Guest
Posts: n/a
 
      3rd May 2007
Hi,

I only need to represent the time, not the day. Is there any other
structure I can use beside DateTime? Because the constructor doesn't
have the ability to take the time alone.

Thanks

 
Reply With Quote
 
 
 
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      3rd May 2007
DaTurk,

You want to use the TimeSpan structure for this.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (E-Mail Removed)

"DaTurk" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I only need to represent the time, not the day. Is there any other
> structure I can use beside DateTime? Because the constructor doesn't
> have the ability to take the time alone.
>
> Thanks
>



 
Reply With Quote
 
Tariq Karim
Guest
Posts: n/a
 
      4th May 2007

I believe there is no structure just to manipulate time. I would suggest
that you can use one of the overloaded constructor of Datetime and
provide minimum date i.e 01/0/01.
Example:
DateTime dt = new DateTime (1, 1, 1, hour, minute, sec).

--
Tariq Karim | Capgemini | El-Segundo
Senior Consultant | Telecom Media and Entertainment
Mobile: +01 832-433-6055 | www.capgemini.com
Join the Collaborative Business Experience


DaTurk wrote:
> Hi,
>
> I only need to represent the time, not the day. Is there any other
> structure I can use beside DateTime? Because the constructor doesn't
> have the ability to take the time alone.
>
> Thanks
>

 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      4th May 2007
Tariq Karim <(E-Mail Removed)> wrote:
> I believe there is no structure just to manipulate time. I would suggest
> that you can use one of the overloaded constructor of Datetime and
> provide minimum date i.e 01/0/01.
> Example:
> DateTime dt = new DateTime (1, 1, 1, hour, minute, sec).


No, Nick's right - TimeSpan is appropriate here. That's what
DateTime.TimeOfDay returns, for example.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Christof Nordiek
Guest
Posts: n/a
 
      4th May 2007
"Jon Skeet [C# MVP]" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> Tariq Karim <(E-Mail Removed)> wrote:
>> I believe there is no structure just to manipulate time. I would suggest
>> that you can use one of the overloaded constructor of Datetime and
>> provide minimum date i.e 01/0/01.
>> Example:
>> DateTime dt = new DateTime (1, 1, 1, hour, minute, sec).

>
> No, Nick's right - TimeSpan is appropriate here. That's what
> DateTime.TimeOfDay returns, for example.
>

It has a disadvantage. It doesn't support format strings similar to
DateTime.
But you still can access single values of minute and hour etc. and construct
a format.

Christof


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DateTime.Now returns incorrect time after time zone change RFlaugher Microsoft Dot NET Compact Framework 8 12th Apr 2010 05:14 PM
Representing a time span in a database James Minns Microsoft Access Database Table Design 3 26th Jun 2006 10:10 PM
DateTime no Time =?Utf-8?B?Y2pl?= Microsoft ADO .NET 1 20th Jan 2005 07:39 PM
How is time represented? How do i make an equation representing 5 minutes? R Microsoft Excel Programming 4 8th Oct 2004 04:56 AM
DateTime Class shows wrong time when Time Zone is changed Dave Hall Microsoft Dot NET Compact Framework 6 14th Jul 2004 06:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:58 AM.