All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
SQL Server 2005 Reporting Services 报表中随意格式化日期的方法_[SQL Server教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/2/3 6:34:53 Browse times: 454 Comment times: 0

SQL Server 2005 Reporting Services 报表中随意格式化日期的方法_[SQL Server教程]


Head photo

Go homepage
Upload pictures
Write articles

SQL Server 2005 Reporting Services 报表中随意格式化日期的方法_[SQL Server教程] 在SQL Server 2005 Reporting Services 报表中格式化日期的方法可以 FormatDateTime的函数,下面是它的定义:
Visual Basic (Declaration)
Public Shared Function FormatDateTime ( _
Expression As DateTime, _
Optional NamedFormat As DateFormat = DateFormat.GeneralDate _
) As String

Visual Basic (Usage)
Dim Expression As DateTime
Dim NamedFormat As DateFormat
Dim returnValue As String
returnValue = Strings.FormatDateTime(Expression, NamedFormat)

下面是NamedFormat 的定义:
Constant
Description

DateFormat.GeneralDate
Display a date and/or time. Display a date part as a short date. If there is a time part, display it as a long time. If present, both parts display.

DateFormat.LongDate
Display a date using the long date format specified in your computer's regional settings.

DateFormat.ShortDate
Display a date using the short date format specified in your computer's regional settings.

DateFormat.LongTime
Display a time using the time format specified in your computer's regional settings.

DateFormat.ShortTime
Display a time using the 24-hour format (hh:mm).

它的类型就这么几种,很有限的,远远不能满足我们的需要。那怎么办?

实际上在报表中可以使用 ToString 的方法,来定义任意格式的字符串格式。比如:
cdate(“2007-12-12 1:3:40”).ToString("yyyy-MM-dd") 可以格式化成 2007-12-12的格式,还可以格式化成12/12/2007这样的格式,甚至可以格式化成 2007+12+12这样的格式。这样只要你的format 格式化字符串正确,就可以实现你想要的日期格式。

来源:网络





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.