SmallDateTime

  • Thread starter Thread starter Smokey Grindel
  • Start date Start date
S

Smokey Grindel

I need to insert a date into sql server via a sproc the table has a
smalldatetime field... because we dont care about things before 1900 or
after 2079.... or the time for that matter... but when I instert a date into
the parameter like this
CmdAddRecord.Parameters.AddWithValue("@BillDate",
SqlDbType.SmallDateTime).Value = now.date

it throws a narrowing error basically on the server... saying it cant
convert from datetime to smalldatetime... how do we go about doing this?
thanks!
 
Actually I am using Add and setting the small date time type :P and it is
giving that error.... I typed that line out by hand and unconciously typed
with value also....
 
Should add I found the problem too turns out our client sends us data and
one of the rows just happened to have a year of 9999.... of course that
errors out on small date time... so my bug turned out to be bad data from
them......
 
Be aware that storing data has always been a problem because there was lack
of space.
For data as numbers, strings, dates and even texts that does not exist
anymore.

Therefore I am curious what is the reason you want to do this, I see not any
benefit.
(Or you should working on a very old database)

Cor
 
I'm confused on what you are talking about? Storing dates as smalldatetime
when the date will never be before 1900 and never after 2079 is the best
choice for file size... and the argument "space is cheap" doesnt work
because memroy and bandwidth to cache and transfer that data isn't... I'd
rather store 1 million dates in 4 byte blocks then 8 byte blocks when I
don't need percision on them more then by a single day...
 
Smokey,

You probably never see a video on your computer,

If you that you spoil bandwidth, and memory for which you can store
100000000000000000000000 datetimes.

Cor
 
I have had that experience before.

Had a client that set unknown expiration dates to 9999. Fun stuff.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
 
In general, the overhead for the larger date is not enough to scrap it for a
small date. The same is true on the bandwidth and time to transfer. I say,
in general, as there are applications for which an extra four bytes per row
can be critical.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
 
Back
Top