select case datefield is null then '' else convert(varchar(10),datefield,120) end
case when 日期字段='1900-01-01' then '' end --在前台應該好處理的吧
显示为1900...是因为日期字段为'',这样试试: declare @t table(s datetime) insert into @t select getdate() insert into @t select null insert into @t select ''select s=nullif(s,'') from @t
我的怎么就显示的空啊 我环境是 vs2003 用的datagrid 显示的
SELECT ISNULL(CONVERT(VARCHAR(10),列,120),'')
1、如果数据是1900-01-01格式,那么就用case when 条件去替换 2 如果是null,那么查询语句就将时间字段查询时转换为字符串类型,上面有几个人就是这么做的 select convert(char(10),时间字段,121),..... from table_Pqs where ............
isnull(时间字段,'')
select case datefield is null then '' else convert(varchar(10),datefield,120) end
--在前台應該好處理的吧
显示为1900...是因为日期字段为'',这样试试:
declare @t table(s datetime)
insert into @t select getdate()
insert into @t select null
insert into @t select ''select s=nullif(s,'') from @t
2 如果是null,那么查询语句就将时间字段查询时转换为字符串类型,上面有几个人就是这么做的
select convert(char(10),时间字段,121),..... from table_Pqs where ............
将查询转为字符串类型到前台显示就不会象时间类型那样null初始化为起始的0值(也就是19000101)了