阿宽

Nothing is more powerful than habit!
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Reporting serverce 中格式化日期

Posted on 2009-08-05 14:57  宽田  阅读(421)  评论(0编辑  收藏  举报
格式化方法1:
      使用FormatDateTime()方法进行格式化。 此种方法缺点是只有五种格式化样式。分别如下:

常数

对应值

说明

DateFormat.GeneralDate

0

显示日期和/或时间。将日期部分显示为短日期。如果有时间部分,则用长时间格式显示。如果两部分都有,则两部分都显示。

DateFormat.LongDate

1

使用计算机的区域设置中指定的长日期格式来显示日期。

DateFormat.ShortDate

2

使用计算机的区域设置中指定的短日期格式来显示日期。

DateFormat.LongTime

3

使用计算机区域设置中指定的时间格式来显示时间。

DateFormat.ShortTime

4

使用 24 小时格式 (hh:mm) 显示时间。


在SQlServer报表工具中(asp.net)用法如下:
=FormatDateTime(Fields!字段.Value,0)

格式化方法2:
      使用CDate()方法。此方可以格式化成任意样式。代码如下:
=CDate(Fields!字段.Value).ToString("yyyy-MM-dd")