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

convert 01/01/0001 to empty string

Tan
I am using ObjectDataSource bind to DetailView which will contain one of the
column with the value type is date. whenver the value of this column is
empty . then it will be display the date in the format ( 01/01/0001), How
can I convert it to empty string or just string?

Thank you very much

tan
Nov 19 '05 #1
5 5204
DateTime type Don't Allow null or empty string.. the only way i found to
workaround this is to convert it to string and check if it's 01/01/0001..
I did myDatetime Class to do this for me when i use ToString() ,
ToShortDateString(),etc...

"Tan @hotmail.com>" <tannguyen88<nospam> wrote in message
news:un****************@tk2msftngp13.phx.gbl...
I am using ObjectDataSource bind to DetailView which will contain one of
the column with the value type is date. whenver the value of this column is
empty . then it will be display the date in the format ( 01/01/0001), How
can I convert it to empty string or just string?

Thank you very much

tan

Nov 19 '05 #2

create class, inherit from DateTime and overload ToString() method
"Tan @hotmail.com>" <tannguyen88<nospam> wrote in message
news:un****************@tk2msftngp13.phx.gbl...
I am using ObjectDataSource bind to DetailView which will contain one of
the column with the value type is date. whenver the value of this column is
empty . then it will be display the date in the format ( 01/01/0001), How
can I convert it to empty string or just string?

Thank you very much

tan

Nov 19 '05 #3
Maybe 01/01/0001 is a default value assigned in the table ?

Check the table's design and see if it is a default value.
If it is a default value, change the default value to null or empty.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Tan @hotmail.com>" <tannguyen88<nospam> wrote in message
news:un****************@tk2msftngp13.phx.gbl...
I am using ObjectDataSource bind to DetailView which will contain one of the column with
the value type is date. whenver the value of this column is empty . then it will be
display the date in the format ( 01/01/0001), How can I convert it to empty string or
just string?

Thank you very much

tan

Nov 19 '05 #4
Tan
I can not inherit from DateTime, in .net 2.0 is a sealed class, any
suggestions?
Tan
"Sebastian Wojciechowski" <sebastian_usenet :this funny sign: icsharp.net>
wrote in message news:Ov**************@tk2msftngp13.phx.gbl...

create class, inherit from DateTime and overload ToString() method
"Tan @hotmail.com>" <tannguyen88<nospam> wrote in message
news:un****************@tk2msftngp13.phx.gbl...
I am using ObjectDataSource bind to DetailView which will contain one of
the column with the value type is date. whenver the value of this column
is empty . then it will be display the date in the format ( 01/01/0001),
How can I convert it to empty string or just string?

Thank you very much

tan


Nov 19 '05 #5
Isn't it simpler to assume that "01/01/0001" is a default value in the
table in question, and that changing that default value to <null>
would simplify the checking/text assignment task ?

Then, checking for IsDBNull / System.DbNull is simple, or use the faster :

bool isNull = (dr[ordinal]==System.DBNull.Value);

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Otis Mukinfus" <Ot**********@newsgroup.nospam> wrote in message
news:l7********************************@4ax.com...
On Wed, 19 Oct 2005 11:55:11 +0100, "Tan" <tannguyen88<nospam>@hotmail.com>
wrote: If you are using .NET 2.0 you can use System.Nullable<T>
Look up System.Nullable in the help file.


I can not inherit from DateTime, in .net 2.0 is a sealed class, any
suggestions?
Tan
"Sebastian Wojciechowski" <sebastian_usenet :this funny sign: icsharp.net>
wrote in message news:Ov**************@tk2msftngp13.phx.gbl...

create class, inherit from DateTime and overload ToString() method
"Tan @hotmail.com>" <tannguyen88<nospam> wrote in message
news:un****************@tk2msftngp13.phx.gbl...
I am using ObjectDataSource bind to DetailView which will contain one of
the column with the value type is date. whenver the value of this column
is empty . then it will be display the date in the format ( 01/01/0001),
How can I convert it to empty string or just string?

Thank you very much

tan

Nov 19 '05 #6

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

Similar topics

7
by: smcgouga | last post by:
Visual Basic 6. ADO 2.8 I have an as400 DB2 V5R1 datasource. Dates are defined as *ISO format and have a range from '0001-01-01' to '9999-12-31'. I am trying to update a date field on the...
1
by: Reza | last post by:
Hi I have a column in my datagrid that can have values of null at times. I am not assigning any value to it, if it is coming from Database empty. Now, the problem is I guess the datetime variables...
1
by: Tan | last post by:
Hello I have a property date in the object data sourse which bind to Detailview, when this date property is null , it will display the date 01/01/0001, how can I convert it to empty string or...
20
by: Niyazi | last post by:
Hi all, I have a integer number from 1 to 37000. And I want to create a report in excel that shows in 4 alphanumeric length. Example: I can write the cutomerID from 1 to 9999 as: 1 ---->...
27
by: fdu.xiaojf | last post by:
Hi, String formatting can be used to converting an integer to its octal or hexadecimal form: '307' 'c7' But, can string formatting be used to convert an integer to its binary form ?
10
by: satishrajana | last post by:
Hi, My SQL returns a NULL in a datefield if there is no date in that field. If there is a NULL in this column, I want to replace it with spaces in my SELECT statement when I am selecting these...
52
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places?...
0
by: =?Utf-8?B?cmF1bGF2aQ==?= | last post by:
vs2005 c# hi: need to convert a simple int to a format nnnn. if I have int 1 I want the result to be padded with 0s as 0001 on a string I have int 1 and I want "0001" any help. Thanks
5
by: Artie | last post by:
Hi, I have a date field stored as an INT and need to convert to a date format mm/dd/yyyy. I'm having trouble determining what the starting date is. min(date) = 730395 max(date) = 733189 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.