【问题标题】:Time still show up in date datatype时间仍以日期数据类型显示
【发布时间】:2013-08-09 05:24:57
【问题描述】:

我在 SQL Server 2008 R2 数据库表中有一个数据类型为 date 而不是 datetime 的列。但在我的水晶报表中仍然是这样的:

 8/4/2013  12:00:00AM
 8/2/2013  12:00:00AM
 8/1/2013  12:00:00AM

不能包括 12:00:00AM,因为数据类型是 date 而不是 datetime 对吗?为什么它仍然出现在报告中?我将如何删除它?

【问题讨论】:

    标签: c# winforms date crystal-reports sql-server-2008-r2


    【解决方案1】:

    这是因为除了少数例外1SQL Server date/time datatypes are mapped to DateTime。如果您不想看到时间组件,请指定适当的 format string 以获得所需的显示格式。例如,

    string today = new DateTime(2013,8,1).ToString("d MMM yyyy") ;
    

    将为您提供 1 Aug 2013 的值(在英语文化中)。

    1time 数据类型映射到TimeSpandatetimeoffset 映射到...等等...@987654330 @。

    【讨论】:

    • 那个格式字符串会在 SQL SERVER 的列公式中吗?
    【解决方案2】:

    右击字段

    点击格式编辑器

    在显示字符串公式中这样写:

    ToText(date({TableName.DateColumn}))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-04
      • 1970-01-01
      • 1970-01-01
      • 2022-01-03
      • 1970-01-01
      • 1970-01-01
      • 2020-03-13
      • 1970-01-01
      相关资源
      最近更新 更多