壹佰网|ERP100 - 企业信息化知识门户

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 296|回复: 0

如何忽略日期列中的时间部分(来自report studio user guide)

[复制链接]
发表于 2012/3/15 00:30:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622  。

您需要 登录 才可以下载或查看,没有帐号?注册

x
如何忽略日期列中的时间部分(来自report studio user guide)
刚刚看了report studio user guide,  看到里面讲了3种方法,在一个日期列里面如何去除时间的部分( 就是去除小时,分,秒的部分),我觉得讲的很好,我没有中文版本,如果有中文版本的朋友,帮忙贴一下

Ignoring the Time Component in Date Columns
Database systems use Date, Time, and Timestamp to represent date and time values. While a
timestamp type holds a date and time component, an application may allow the RDBMS to
default the time component. When rows are inserted, updated, or queried, the application may
specify only a date value and leave the RDBMS to extend the value to include a default time
(usually 00:00:00.000).
The challenge with a timestamp is when the application has no immediate interest in the time
component. For example, the business question "How many orders were taken today?" implies
all orders taken irrespective of what time in the day the order was booked. If the application
defaulted the time component as it stored rows, the query used to answer the question returns the
count of orders taken today. If the application stored the actual time component, the query likely
returns no data, because the number of orders entered at midnight is probably zero.
Relying on dates defaulting the time can be dangerous if the application changes and starts to
capture actual times. To avoid this problem, you can use the followed motheds

Truncating the Time by Creating a Derived Column
In the Framework Manager model, create a derived column using a calculated expression that
truncates the time from a timestamp, and returns a timestamp containing the original date and a
default time. For example, if you use an Oracle data source, the following expression creates the
derived column DATEONLY from COL1, where COL1 contains the values as stored by the
application while DATEONLY contains the dates with the default time of 12:00:00 AM:
Select COL1,trunc(COL1) as DATEONLY from [SCOTT_TIGER].DATES
Tip: You can change the data format of the column to show only the date value by specifying
Short for the Date Style property.
You can then apply filters to the DATEONLY column that would return the correct results. If you
create a parameter in Report Studio that filters on this column, the default prompt will present a
date and time control because the data type is still a timestamp.

Converting the Timestamp to a Date
In the Framework Manager model, define a calculation that uses the CAST function to convert the
timestamp to a date. For example, the following expression converts the data type of the column
COL1 to date:
cast ([SCOTT_TIGER].[DATES].[COL1],DATE)
If you create a parameter in Report Studio that filters on this calculation, the default prompt
presents a date control.

Ignoring the Time by Creating a Hi-Low Filter
You can create a filter to ignore the time. In the Framework Manager model, create a filter in the
form date-column between date-lowtime and date-hightime. For example, the following
expression returns all values between 00:00:00:000 and 23:59:59:000 for a given day:
[SCOTT_TIGER].[DATES].[COL1] between
?p1? and cast(substring(?p1?,1,10),’23:59.59.000’,timestamp
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|手机版|壹佰网 ERP100 ( 京ICP备19053597号-2 )

Copyright © 2005-2012 北京海之大网络技术有限责任公司 服务器托管由互联互通
手机:13911575376
网站技术点击发送消息给对方83569622   广告&合作 点击发送消息给对方27675401   点击发送消息给对方634043306   咨询及人才点击发送消息给对方138011526

GMT+8, 2025/11/30 07:05 , Processed in 0.011601 second(s), 16 queries , File On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表