博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
RDLC报表格式化format表达式
阅读量:6978 次
发布时间:2019-06-27

本文共 1359 字,大约阅读时间需要 4 分钟。

刚开始接触RDLC报表,觉得RDLC报表提供的格式化工具太少,不像Crystal Report一样那么多的API支持,用起来多少的灵活啊。

由于RDLC报表中有相关的日期格式字段,因此自然而然的就需要对日期字段进行格式化了,搜索了一些文章都是在介绍

FormatDateTime函数,其实用起来就发现FormatDateTime不是我要的料,这此先看看FormatDateTime的声明吧:

 

Function 
FormatDateTime(
   
ByVal Expression 
As DateTime,
   
Optional 
ByVal NamedFormat 
As DateFormat = DateFormat.GeneralDate
As 
String
DateFormat是一个枚举,其值很少不太适合中国人制作报表的习惯,

NamedFormat 参数具有下列设置:

常量 说明
DateFormat.GeneralDate 显示日期和/或时间。如果有日期部分,则用短日期格式显示。如果有时间部分,则用长时间格式显示。如果二者都有,则两部分都显示。
DateFormat.LongDate 使用计算机的区域设置中指定的长日期格式来显示日期。
DateFormat.ShortDate 使用计算机的区域设置中指定的短日期格式来显示日期。
DateFormat.LongTime 使用计算机区域设置中指定的时间格式来显示时间。
DateFormat.ShortTime 使用 24 小时格式 (hh:mm) 显示时间。

 

FormatDateTime(Fields!PlanStartDate.Value,DateFormat.ShortDate)

 

Command Result
FormatDateTime(Parameters!Date.Value,1) Tuesday, April 10, 2007
FormatDateTime(Parameters!Date.Value,2) 4/10/2007
FormatDateTime(Parameters!Date.Value,3) 12:00:00 AM
FormatDateTime(Parameters!Date.Value,4) 00:00
 
如果我想通过FormatDateTime将日期格式显示成“2012年4月”,那就很难了。

 

 

 解决方法

The Format command and specify the exact format you require.

好Format函数现已隆重出场了,因此他确实可以解决我的问题,而且使用习惯与DateTime.ToString()类似,非常简单:

Command Result
Format(Parameters!Date.Value,"dd-MM-yyyy") 10-04-2007
Format(Parameters!Date.Value,"dd/MM/yyyy") 10/04/2007
Format(Parameters!Date.Value,"MMM-dd-yyyy") Apr-10-2007
Format(Parameters!Date.Value,"MMM-dd-yy") Apr-10-07

 

转载地址:http://hmupl.baihongyu.com/

你可能感兴趣的文章
自定义classloader中的接口调用
查看>>
python依赖包exe文件安装问题
查看>>
namenode如何存储复本?
查看>>
apache ab压力测试
查看>>
微信扫描二维码登入实现,网页端
查看>>
Python中is同一性运算符和==相等运算符区别
查看>>
ios项目文件结构 目录的整理
查看>>
javassist学习笔记
查看>>
JAVA中的并发工具 -- CountDownLatch、CyclicBarrier、Semaphore
查看>>
Dubbo原理何源码解析之服务暴露
查看>>
牛人学习记录
查看>>
python-range用法
查看>>
常用的正则表达式
查看>>
服务器的定义
查看>>
solrj操作单机solr
查看>>
Java架构演进之路
查看>>
chsop 兼容jquery(解决与transport.js冲突)
查看>>
tar常见文件解压法
查看>>
Oracle 表空间扩容
查看>>
python 查询 elasticsearch 常用方法(Query DSL)
查看>>