SmallDateTime.MinValue??

  • Thread starter Thread starter Marc Pelletier
  • Start date Start date
M

Marc Pelletier

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
 
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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Compare... 4
Expand Range into List 2
SqlDateTime and DateTime 2
comparing nullables 3
DataRowCollection.Find Method 4
I couldn't see what the method would do 11
Base Class 1
Extend Types like instances? 8

Back
Top