473,322 Members | 1,734 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,322 software developers and data experts.

How do I null a date?


C#

I have a data entry screen where one of the options is to enter a start and
end datetime. Mostly there will not be an end time. But I cant display no
date in the datetime field on the screen, and I cant send a null date to my
stored procedure. How do I do this?

Thanks

Ste
Feb 6 '06 #1
5 1332
A date is a value type and therefore can't be set to null. You pass
DbValue.Null.

Check the msdn for a closer description.

Greetings,
Eduard Ralph

Feb 6 '06 #2
You could use DateTime.MinValue;

"Eduard Ralph" wrote:
A date is a value type and therefore can't be set to null. You pass
DbValue.Null.

Check the msdn for a closer description.

Greetings,
Eduard Ralph

Feb 6 '06 #3
when I want a date to be null, i just set its value to: 1/1/1901 which
I beleive is the DateTime.MinValue like Eduard mentioned.

Feb 6 '06 #4
Is the end date field in the database table non-nullable? If it is
nullable, you can simply make the parameter optional in the stored
procedure.

Regards,
Jim

Feb 6 '06 #5
guy
if you are using 2005, you can use the Generic Nullable which effectively
makes a value type nullable.

eg dim MyDate as Nullable(of date)

http://msdn.microsoft.com/library/de...tFramework.asp

hth

*guy*
"Steve" wrote:

C#

I have a data entry screen where one of the options is to enter a start and
end datetime. Mostly there will not be an end time. But I cant display no
date in the datetime field on the screen, and I cant send a null date to my
stored procedure. How do I do this?

Thanks

Ste

Feb 7 '06 #6

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

Similar topics

6
by: Kris M | last post by:
How do i handle a null value for a date variable type. I am retrieving date data from an access database and storing the records in an array for processing. The array field has a date type and the...
8
by: Lyn | last post by:
I am trying to get my head around the concept of default, special or empty values that appear in Access VBA, depending on data type. The Access Help is not much (help), and the manual that I have...
5
by: tshad | last post by:
I have the following code: *************************************************************************** Dim CommandText as String = "INSERT INTO ftsolutions.dbo.position (client,dateposted) VALUES...
6
by: Dean Slindee | last post by:
I am looking for the "right" way to handle inserting and presenting null date values. Public Const c_NullDate As Date = #12:00:00 AM# If I set the value of a date variable in an SQL Server insert...
9
by: John Sidney-Woollett | last post by:
Hi I'm building a web app where changes to customer orders are logged in the following table, and I worried about the time that it will take to locate records that need further...
6
by: recif20002002 | last post by:
Hello I am trying to update table1 and set a new value with a condition selecting only the results for the element with the specified ID and the first one with the Date field null. The query...
5
by: Amogh | last post by:
Hi, My question is related to setting freed pointers to NULL. After freeing a pointer: 1) Should the freeing routine also be responsible for setting the pointer to null? 2) Or, should the...
5
by: AAJ | last post by:
Hi Does anyone know of any good publically available set of standards for managing dates when dealing with a database server (in my case SQL Server 2000 and c# VS2005). At the moment, if I...
5
by: M Skabialka | last post by:
I am creating my first Visual Studio project, an inventory database. I have created a form and used written directions to add data from a table to the form using table adapters, data sets, etc. ...
3
by: cmartin1986 | last post by:
I have written a sql query and I need it to return 0 when it doesn't find any matches to my criteria. I have tried adding iif statements, tried sum, and just Count, all of these methods work fine to...
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
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...
1
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
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.