惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
O
OpenAI News
Cloudbric
Cloudbric
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Help Net Security
Help Net Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tenable Blog
S
Security @ Cisco Blogs
N
News and Events Feed by Topic
The Hacker News
The Hacker News
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
V
Visual Studio Blog
P
Proofpoint News Feed
Webroot Blog
Webroot Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
L
LangChain Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东

博客园 - 振河

SQL Server 2005 Reporting Services动态设置数据源 在windows 2008 server 中Password must meet complexity requirements VS2005 中控件的 GenerateMember 属性 WCF 安全之自定义的用户名/密码身份验证 Visual Studio 2008 开发WPF应用程序系列文章——window class 之间的继承 Visual Studio 2005 开发WPF应用程序系列文章——什么是WPF 配置 SQL Server 2005 远程调试存储过程 (转载) C# Office编程——Word 错误类型:“系统找不到 Microsoft.Office.Interop.Word" Reporting Service 在文本框中换行的问题 数据库范式设计 JavaScript 用DIV模拟弹出窗口并跟随窗体滚动 SQL Server 2000 占内存居高不下可能的原因及其解决方法 轻松移除VS2005解决方案中的VSS绑定信息 使用ComponentOne 中 C1TrueDBGrid 实现Master-Detail Grid Reporting Services 运行时设置报表的Page Header的大小 朋友,5.1节日快乐 SQL Server 2005 Reporting Services 使用C#类库中的函数方法 SQL Server 2005 Reporting Services的一个bug及其解决方法 SQL Server 2005 Reporting Services 在排版上存在的一个问题
SQL Server 2005 Reporting Services 报表中随意格式化日期的方法
振河 · 2007-01-25 · via 博客园 - 振河

在SQL Server 2005 Reporting Services 报表中格式化日期的方法可以 FormatDateTime的函数,下面是它的定义:

Visual Basic (Declaration)
Public Shared Function FormatDateTime ( _
            Expression As DateTime, _
            <OptionalAttribute> 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 格式化字符串正确,就可以实现你想要的日期格式。