470,614 Members | 1,491 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,614 developers. It's quick & easy.

SmallDateTime.MinValue??

Hello all,

I have a library of datetime routines that make things simpler for me.
Before I discovered DateTime.MinValue I had a function that looked like

public static DateTime DayZero { get { return new DateTime( 0,0,0); } }

I use it to compare for nonvalid datimes in some code, for example if
moonrise equals DayZero then the moon doesn't rise on that day.

Now I am SOOO much smarter and I refer to DateTime.MinValue instead. Is
there a simple way to get the equivalent result for a smalldatetime field?

Right now I am using

public static DateTime SmallDayZero {get {return new DateTime(1900,1,1);} }

to test if a value will fit into the smalldatetime field in a database, but
I suspect there is a better way.

Any ideas?

Thanks

Marc Pelletier
Nov 16 '05 #1
2 6641
Marc,

This is probably the best way to do it. If anything, you should set the
SmallDayZero field to be readonly, so that it can't be changed by your
application (it's not ever going to change).

The SqlDateTime structure is used to represent both regular datetime
values and smalldatetime values in .NET, so you can't use the Min on that.
You will have to define it yourself.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Marc Pelletier" <no******@please.com> wrote in message
news:Xn*********************@216.168.3.44...
Hello all,

I have a library of datetime routines that make things simpler for me.
Before I discovered DateTime.MinValue I had a function that looked like

public static DateTime DayZero { get { return new DateTime( 0,0,0); } }

I use it to compare for nonvalid datimes in some code, for example if
moonrise equals DayZero then the moon doesn't rise on that day.

Now I am SOOO much smarter and I refer to DateTime.MinValue instead. Is
there a simple way to get the equivalent result for a smalldatetime field?

Right now I am using

public static DateTime SmallDayZero {get {return new
DateTime(1900,1,1);} }

to test if a value will fit into the smalldatetime field in a database,
but
I suspect there is a better way.

Any ideas?

Thanks

Marc Pelletier

Nov 16 '05 #2
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in news:Oq*************@TK2MSFTNGP11.phx.gbl:
The SqlDateTime structure is used to represent both regular
datetime
values and smalldatetime values in .NET, so you can't use the Min on
that. You will have to define it yourself.

Hope this helps.


It does, thanks.

Marc
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Joey Martin | last post: by
2 posts views Thread by Rey | last post: by
2 posts views Thread by .Net Sports | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.