I have to display Datetime in my gridview, the problem is that while I am inserting values to the database, for default date I am passing "1/1/1900", so when retrieving the data I found the value "01/01/1900 12:00:00 AM" in gridview.
我必须在gridview中显示Datetime,问题是当我向数据库插入值时,对于默认日期我正在传递“1/1/1900”,所以在检索数据时我发现值为“01/01 / 1900 12:00:00 AM“在gridview中。
If the datetime is "01/01/1900 12:00:00 AM" I want it as a null value or the corresponding date, can I check this in a stored procedure? Pls help...
如果日期时间是“01/01/1900 12:00:00 AM”我希望它作为空值或相应的日期,我可以在存储过程中检查这个吗?请帮忙......
2 个解决方案
#1
SELECT
CASE
WHEN DateField = '01/01/1900 12:00:00 AM' THEN NULL
ELSE DateField
END AS DateField
FROM
Wherever
#2
in place of storing default date you can set the date as null when inserting to avoid future mistakes and use like.why to make things messy just use
代替存储默认日期,您可以在插入时将日期设置为null,以避免将来出现错误并使用like.why使事情变得混乱只是使用
Select ISNULL(DateField,'what everyou want to show in Grid when NULL') as DateField From YOURTABLE
OR
Select DateField from YOURTABLE
#1
SELECT
CASE
WHEN DateField = '01/01/1900 12:00:00 AM' THEN NULL
ELSE DateField
END AS DateField
FROM
Wherever
#2
in place of storing default date you can set the date as null when inserting to avoid future mistakes and use like.why to make things messy just use
代替存储默认日期,您可以在插入时将日期设置为null,以避免将来出现错误并使用like.why使事情变得混乱只是使用
Select ISNULL(DateField,'what everyou want to show in Grid when NULL') as DateField From YOURTABLE
OR
Select DateField from YOURTABLE