471,337 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

storing pure dates and pure times

What are some best practices for storing pure dates and pure times in .NET ?

I notice that DateTime.TimeOfDay() returns type TimeSpan , which is
certainly sufficient for storing pure times , but not constrained ...

Do people write their own classes ? Or have I overlooked one or more
intrinsic .NET classes ?
Sep 16 '08 #1
4 1750
Hi John,

i mostly strore culture specific dates and times with
my applications, mostly as a string, created from
DateTime.Now.ToString() which is bound to a
specific culture. Thats what is mostly handy for me,
but you should have a look at this link:

[.NET Development (General) Technical Articles
Coding Best Practices Using DateTime in the .NET Framework]

http://msdn.microsoft.com/en-us/library/ms973825.aspx

Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.codeplex.com/restarts
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"John A Grandy" <johnagrandy-at-gmail-dot-comschrieb im Newsbeitrag
news:eG**************@TK2MSFTNGP06.phx.gbl...
What are some best practices for storing pure dates and pure times in .NET
?

I notice that DateTime.TimeOfDay() returns type TimeSpan , which is
certainly sufficient for storing pure times , but not constrained ...

Do people write their own classes ? Or have I overlooked one or more
intrinsic .NET classes ?
Sep 16 '08 #2
<"John A Grandy" <johnagrandy-at-gmail-dot-com>wrote:
What are some best practices for storing pure dates and pure times in .NET ?

I notice that DateTime.TimeOfDay() returns type TimeSpan , which is
certainly sufficient for storing pure times , but not constrained ...

Do people write their own classes ? Or have I overlooked one or more
intrinsic .NET classes ?
I assume by "pure date" you mean "date without a time". I'd probably
use DateTime or create my own structure which could be converted
to/from DateTime.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Sep 16 '08 #3
On Sep 16, 2:22*pm, "John A Grandy" <johnagrandy-at-gmail-dot-com>
wrote:
What are some best practices for storing pure dates and pure times in .NET ?

I notice that DateTime.TimeOfDay() returns type TimeSpan , which is
certainly sufficient for storing pure times , but not constrained ...

Do people write their own classes ? *Or have I overlooked one or more
intrinsic .NET classes ?
What is wrong with the DateTime from the framework?
If you want to just use Dates , you can simply ignore the Time
component.
Not only that but can strip any DateTime of the time component by
using DateTime.Date

I do not know of any "pure time" struct. You can use a DateTime with a
fixed Date component. then you only have a Time delta.
Sep 16 '08 #4
What's wrong with it ? Well, perhaps this is a glib answer, but SQL Server
2008 will have separate datatypes for pure time , pure date , and date-time,
and it would be nice to have some congruency in C# ...

But more fundamentally, I think it's asking for trouble to allow a datatype
to contain irrelevant and/or impossible values for the underlying entity
being modeled ...
"Ignacio Machin ( .NET/ C# MVP )" <ig************@gmail.comwrote in
message
news:e8**********************************@z72g2000 hsb.googlegroups.com...
On Sep 16, 2:22 pm, "John A Grandy" <johnagrandy-at-gmail-dot-com>
wrote:
What are some best practices for storing pure dates and pure times in .NET
?

I notice that DateTime.TimeOfDay() returns type TimeSpan , which is
certainly sufficient for storing pure times , but not constrained ...

Do people write their own classes ? Or have I overlooked one or more
intrinsic .NET classes ?
What is wrong with the DateTime from the framework?
If you want to just use Dates , you can simply ignore the Time
component.
Not only that but can strip any DateTime of the time component by
using DateTime.Date

I do not know of any "pure time" struct. You can use a DateTime with a
fixed Date component. then you only have a Time delta.
Sep 16 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Robert | last post: by
8 posts views Thread by Zvonko | last post: by
5 posts views Thread by Steve | last post: by
36 posts views Thread by Lindie | last post: by
13 posts views Thread by junky_fellow | last post: by
6 posts views Thread by Miguel Guedes | last post: by
reply views Thread by rosydwin | last post: by

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.