473,320 Members | 2,146 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,320 software developers and data experts.

Datetime field in SQLserver database empty?

Hi,

I've got the next problem: I have a datetime field in my database
(sql-server) and I want the option in it that this field can be empty. But
if I leave that datetime field empty I get the error:

"The value you entered is not consistent with the data type or length of the
column."

Is it possible to leave that field empty and how is it possible? If not what
do I have to do to leave it empty, because in my application this (date) is
not a required field?

Thanks for your help,

Thierry
Nov 18 '05 #1
1 1964
If someone else knows a better way I'm all ears,

The only way I know how to have a truly empty date is to allow nulls in the
datetime field. Then in code, you can set the variable you are updating
with to System.DBnull.Value. Or if you are working off typed datasets, you
can use myDataSet.myTable(rowNum).setField_NameNull(), at least something
like that I'm not sure if that syntax is correct.

--Michael
"Thierry" <Th*****@nospam.com> wrote in message
news:rX*********************@phobos.telenet-ops.be...
Hi,

I've got the next problem: I have a datetime field in my database
(sql-server) and I want the option in it that this field can be empty. But
if I leave that datetime field empty I get the error:

"The value you entered is not consistent with the data type or length of the column."

Is it possible to leave that field empty and how is it possible? If not what do I have to do to leave it empty, because in my application this (date) is not a required field?

Thanks for your help,

Thierry

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: colinhumber | last post by:
I have a datetime variable coming from my ASP.NET application that has a time portion. I give my users the option to perform an equals, greater than, less than, or between comparison. The trouble...
1
by: v0lcan0 | last post by:
Any help on extracting the time part from the datetime field in SQL database. even though i had entered only the time part in the database when i extract the field it gives me only the date...
6
by: Carl | last post by:
Hi, to be use with SQL server database 1- From window form textbox object From this assignement, txtTOTAL.Text="0.00m"; How do you convert back to decimal type ? How do you assign a...
8
by: Gidi | last post by:
hello, i have a textbox that represnts a date and i want to pare it to a DateTime, but sometimes this textBox can be empty string and i want to send it to the DataBase as null or as empty Date, how...
2
by: Rey | last post by:
Howdy all. My problem deals w/inserting nulls into database (SQL Svr 2K) for the datetime fields activityDate and followUpDate where nulls are allowed. >From the web form, the user can type...
1
by: RossM | last post by:
Hello, I am designing a page in ASP and using MSSQL for the database. I want to use an if statement saying that if the field is empty, display something, else display something else. However...
1
by: Brad Pears | last post by:
I am using vb.net 2005 and SQL server 2000. In my table I have a date field of type "smalldatetime". In my vb application, the user may or may not enter a date value into the appropriate text box....
7
by: gr8Ashish | last post by:
Hi all, I am facing a problem. I create a application that is insert date and time in SQL Server 2005 table from web page then i fetch this datetime type field in vb.net application and adding some...
3
by: chandhseke | last post by:
Hi folks, I have designed a webpage using asp, i have a text box with a calender in the page from which the user will select a date. since the date field is not mandatory, if this field is left...
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...
1
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.