473,241 Members | 1,480 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,241 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 1832
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Robert | last post by:
I have no problem storing dates + times in a System.DateTime object. In addition, it's easy to output a Time as a string from an existing Date/Time. But I'm having trouble storing a time only. ...
8
by: Zvonko | last post by:
Hi! I would like to get the clients date and time (his system time) and store it somewhere so I can use it in my code later. (insert it to database!). Any ideas Zvonko
5
by: Steve | last post by:
I am currently trying to validate data in an access database. I need to verify that columns containing date information are in the format ddmmyyyy and columns containg time information are in the...
36
by: Lindie | last post by:
The more I read the more confused I get. Too much on dates calulations in the groups. I need to know how often a book has been loaned out over the past year- 52 weeks. My table has Book...
13
by: junky_fellow | last post by:
I have read certain articles that encourage to use/write pure functions (if possible) as they are better suited for optimization. I got one example that expalins how the code can be optimised....
3
by: Stephen | last post by:
Hi, I have a table consists which cosists of batch numbers, and assosiated dates and times..ie the columns are batch, date and time. The data within the table is not in any particular order. ...
7
by: fauxanadu | last post by:
Is it possible to store dates before 01/01/0100 A.D. (such as for as database storing world events would require) using MS Access? Verbose Explination I need to be able to store dates before...
2
by: billelev | last post by:
Hi there, Does anyone know how to store a constant in VBA that is set using a function or sub-routine? Here is the scenario. When I load up Access for the first time, I'd like to calculate...
6
by: Miguel Guedes | last post by:
Hello, I recently read an interview with Bjarne Stroustrup in which he says that pure abstract classes should *not* contain any data. However, I have found that at times situations are when it...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.