Null date textbox returns 01/01/1900 instead of null

VS 2005, SQL Server 2000

For the following textbox, if the textbox is blank when I do an update, it returns 01/01/00 (which is 01/01/1900).  Is there a way to prevent it from entering a value when it should be null, or do I need to do a check in the Updating event?

<asp:TextBox ID="ResolvedDate" Text='<% #Bind("ResolvedDate","{0:MM/dd/yy}")%>'  runat="server" ></asp:TextBox>

6/22/2007 6:20:57 PM 93655 articles. 6 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 9
Get it on Google Play
Get it on Apple App Store

I'm a little confused... Do you mean, when the page loads, the textbox has 01/01/1900... OR do you mean, when the page posts back, it contains the value 01/01/00? I'll assume you mean the former. If that's the case, you need to change how you do your databinding in the textbox.. I would probably do something like this:

Create a function in your codebehind like this

 Public Function GetDateValue(text As String) As String

    If text is DBNull.Value Then

        Return ""


      Return text

    End If 

End Function

 Then, change your textbox to look like this


<asp:TextBox ID="ResolvedDate" Text='<%# GetDateValue(Bind("ResolvedDate","{0:MM/dd/yy}")) %>'  runat="server" ></asp:TextBox>

That's the idea, but since I just whipped that up while waiting for someone to call, it might not work perfectly the first time you try. :)

Alex Dresko
I'm not a player, I just code a lot.
6/22/2007 6:46:32 PM

that is the default date to display when the value is null, try setting it to just be blank ie "". in my sql stuff for dates i would do isnull(database.value,'''') which sets the value to "" if it is null at the sql level

Please remember to click "Mark as Answer" on this post if it helped you.
6/22/2007 6:50:32 PM

If the date field is <NULL> in SQL Server 2000, it shows up blank on my Web form.  If I don't touch that field but do an update and check the SQL Server table directly, it contains 1/1/1900!

6/26/2007 3:01:17 PM

 Yes that will display like that only, to get current date when text filed is null u use defaultvalue as getdate()to that date column ot other wise

asign current value in program like

cmdInsert.Parameters["@CaseDateTime"].Value = System.DateTime.Now.ToString();

try like this

all d best


6/26/2007 3:26:49 PM

Similar Artilces:

NULL DATE IS NOT NULL BUT 01/01/00 00:00
The following works if I'm in design mode, but it doesn't in the release version. I got a column field with a mask as mm/dd/yy hh:mm, when the value is null, it shows 00/00/00 00:00 which is what I want, but when user wants to delete an existing date, let's say 06/05/02 12:00, instead of going back to 00/00/00 00:00 it goes to 01/01/00 00:00. I am using PB 8 Ent and W2K operating system, database is in SQL2000. If I look at the value in the database it got 01/01/00 instad of <NULL>. try check 'blank is null' @ datawindow field setting... & allow ed...

Convert 01-01-1900 Date string value to NULL
Hi   I have a number of Textboxs on a Formview.   The Textboxs contains Date values.   When I update these dates are saved to SQL Default 1/1/1900.   I know I have to Convert Date string value to NULL before UPDATE query is executed Or write a trigger to replace 1/1/1900 values to null   I cannot find a way of converting Date back to NULL.   Also, I have only written very simple triggers.   Could anyone help me on to how to achieve the above?   Thanks in advance.   Using VB 2005/SQL 2005 Have default datetime value i...

Inserting a NULL value instead of 01/01/1900 12:00:00 a.m.
Hello, I'm trying to save data from my page but even when I'm adding the NULL value in my query is still saving the 01/01/1900 12:00:00 a.m. in my datetime field This is my code:   Dim sqlConn As SqlConnection Dim sqlCmd As SqlCommand Dim strConnection, resul, COP, USD As String strConnection = ConfigurationManager.ConnectionStrings("SIPConnectionString").ConnectionString sqlConn = New SqlConnection(strConnection) COP = Replace(TxtCOP.Text, ".", ",") USD = Replace(TxtUSD.Text, ".", ",") resul = "Insert into...

Date function return 1900/01/01
I have a datetime column. I want to get it value and compare to another datetime column. Here is my script in itemchanged datetime ldt_source, ldt_target string ls_date ls_date = gettext() ====> return 2002/10/16 00:00:00 ldt_source = date(ls_date) ====> return 1900/01/01 How do I convert a string to date, ref to help. It is using date(). But it return 1900/01/01 It's strange that you don't get a compile error. ldt_source is datetime In that case you should do something like: ldt_source = Datetime(Date(ls_date)) What you can always do is strip of the t...

date is 01/01/1900
I am using PB12.1 and MS SQL Server 2008 R2 Express , and I am connect through SNC I have code like::- ls_date = "28/12/2010" format is dd/mm/yyyy date ldt_date ldt_date = date(ls_date) but it gives date=01/01/1900 it means null date and in control panel\reginal setting I change date format to dd/mm/yyyy but problem still, could any one help me thanks I just answered this question in the general section. Please don't crosspost - answers are more useful if the discussion is all in one place. Report Bugs to Sybase: ...

Nulls, Nulls and More Nulls...
Hi guys,I'm working with some null values in my database(SQL SERVER2000). So, where is null in the database I transform it in the program, like this:Dim dr as DataReader.....         If dr.IsDBNull(34) = True Then   '<--this number, (34) is the column number of the record in the database...                  DropDownList16.SelectedIndex = 0   '<-- If the value in the database is null, I tell to the ddl to sel...

date is 01/01/1900
I am using PB12.1 and MS SQL Server 2008 R2 Express , and I am connect through SNC I have code like::- ls_date = "28/12/2010" format is dd/mm/yyyy date ldt_date ldt_date = date(ls_date) but it gives date=01/01/1900 it means null date and in control panel\reginal setting I change date format to dd/mm/yyyy but problem still, could any one help me thanks That says the input was not recognized as a valid format - null input would return null. It's a better practice to use PB's date literal format "yyyy-mm-dd" to avoid problems, as the control panel se...

date is 01/01/1900
I'm updating a row in sql2k and its updating my date field to 01/01/1900 no matter what I specify. Am I doing this correctly: UPDATE Purchase SET DOP = 25/03/2003 WHERE Code = 'code02' I'm using query analyzer also, same thing, although row updated successfully is 1. > UPDATE Purchase SET DOP = 25/03/2003 WHERE Code = 'code02' try : UPDATE Purchase SET DOP = '25/03/2003' WHERE Code = 'code02' or in access UPDATE Purchase SET DOP = #25/03/2003# WHERE Code = 'code02' though I usually try to use non-ambiguos date formats e.g. UPDATE Purchase SET DOP = '25 Mar...

Default Date 01/01/1900 ro current date
Is there a way to change the PB default date of 01/10/1900? Is it a built-in setup or is there a setting I can change to make it use the current date instead of 10/10/1900? Thanks for your help! No. I believe PB uses an "epoch" integer for internal date storage, and 01-jan-1900 is what 0 translates to. You're just going to have to initialize ate variables as needed. <Anna> wrote in message > Is there a way to change the PB default date of 01/10/1900? > Is it a built-in setup or is there a setting I can change t...

1900/01/01 date issue
Hi, I have two date fields(date1 and date2) on a dw, both with editmasks in yyyy/mm/dd format. When the user enters 0000/00/00 in the first date field (date1), debugger shows date1's value as 1900/01/01 - the default value for invalid dates as I understand. The application has processing in the itemchanged event of this dw to SetNull date2 if date1 = 1900/01/01 and if not, do some processing and display a new date in date2. Is there a standard work around to allow the user to enter 1900/01/01 in date1, check for invalid dates, and still allow normal processing (perform the ca...

Hide 1900-01-01 date in GridView
I use a Calendar in a GridView. I found the Calendar does not like the NULL from the database so I replaced NULL by SqlDateTime.Null which is actually the date 1900-01-01. So now I see 1900-01-01 in the GridView. How could I replace 1900-01-01 by nothing in the GridView ? Hi Guy,  I have done something similar with the following code using the pre render event for the grid view:   Protected Sub GridView1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.PreRender For Each r As GridViewRow In GridView1.Rows If r.Cells(<da...

Updating database date field results in date value of "01/01/1900"
Brand new to this, so please bear with me.I'm using the following code fragment to update a datetime field on a SQL Server 2005 database table:cmd.CommandText = "Update Projects Set EntryDate = " & Convert.ToDateTime(txtEntryDate.Text)cmd.ExecuteNonQuery()The result of the update operation is the the database field contains the value "1900-01-01 00:00:00:000".  This probably means that I passed nulls to SQL; however, I see a valid date in the txtEntryDate field on my web form (i.e., "06/18/2007").  I also did a "Response.write" t...

Returning null, the .net client dont get null
I have a java (axis 1.4) web service, My web service return an object, but when the object is null, the .net client don't get object= null, It get object.field1=0, object.field2="" ...Where is the problem?Thankss The webservice response is this:<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="" xmlns:xsd="" xmlns:xsi=""><soapenv:Body><getVariableAnalogicaPorConsignaRe...

Thank you Vinay All these doubts b'coz i am new to PB specially to DataWindows What does below code in the edit source code of datawindow specify? Also what is its use? data(null,null.null) or data(1,2,3,4,5,6,7,8,9) Also what is the use of the compute feild int the retrieve statement of datawindow? Thank you Hi which ver of PB If you add blank row in data tab of the (default data ) for datawindow you will find the data(null..) If you put values then you will find data(your value1,...) Which type of coumputed field you talking about? -- Regards Vinay...

Web resources about - Null date textbox returns 01/01/1900 instead of null -

Aqua (user interface) - Wikipedia, the free encyclopedia
Aqua is the GUI and primary visual theme of Apple Inc. 's OS X operating system . It is based around the theme of water, as its name suggests, ...

Wikipedia:Sockpuppet investigations - Wikipedia, the free encyclopedia
WP:RFCU redirects here. You may be looking for Wikipedia:Requests for comment/User conduct ( WP:RFC/U ), CheckUser policy ( Wikipedia:CheckUser ...

Help - is a social service . Users can post short(140 character) status messages which are broadcast totheir friends and colleagues on the ...

City of Whitehorse, YT : Contact
Employment - Bylaws - Document Library - FAQ - Contact Us Search Query Textbox Home Home About Whitehorse Notify Me Contact Us Employee Links ... Help
Help for uploading pictures Noun explanation Group pictures: a basic unit which stands for a piece of news photo in system; include: information ...

Metamorphose: All-In-One File/Folder Renamer For Windows, Mac & Linux
Previously, we’ve reviewed many batch file-renaming applications like ReNamer (read review), NameChanger (read review), File Grinder (read review) ...

How to build a Twitter extension for Chrome
Ars takes a close look at the Chrome Web browser's new extension system. In …

ASUSTeK Computer Inc. -Support- RSS
... RSS Service, please follow the instructions below. STEP 1. Select the product to subscribe. STEP 2. The RSS link will be shown on the Textbox ...

authonomy writers and readers - Daniel Escurel Occeno's profile - authonomy writing community
... of the Point Guard”. It is entered in writing contest.In the TEXTNOVEL website simply type in “Lee Chon” in the textbox search ...

Baseball Prospectus
Forgot Your Password? Enter your username in the textbox below. Username: If you don't remember your username, please contact Customer Service ...

Resources last updated: 2/11/2016 2:27:35 PM