How do I use register in a stored procedure?

I need to display Datetime in my gridview, the problem is that while I am inserting values ​​into the database, for the default date I am passing "1/1/1900", so when I get the data I found the value "01/01/1900 12 : 00: 00 AM "in the gridview.

If the datetime is "01/01/1900 12:00:00 AM", I want it to be a null value or the corresponding date, can I check this in a stored procedure? Pls help ...

0


a source to share


2 answers


SELECT
    CASE
        WHEN DateField = '01/01/1900 12:00:00 AM' THEN NULL
        ELSE DateField
    END AS DateField
FROM
   Wherever

      



+3


a source


instead of storing the date by default, you can set the date to null on insertion to avoid future errors and use like.why to make things messy, just use

Select ISNULL(DateField,'what everyou want to show in Grid when NULL') as DateField From YOURTABLE

      



OR

Select DateField from YOURTABLE

      

0


a source







All Articles