I am using Crystal Reports 2013 SP5 on Windows 7 Pro pulling from an Oracle db.
我在Windows 7 Pro上使用Crystal Reports 2013 SP5从Oracle数据库中提取。
I am trying to write a formula(s) in crystal reports that returns the total number of days the remaining hours if less than 24, and the remaining minutes if less than 60 from a datediff between two date time fields.
我试图在水晶报告中写一个公式,如果小于24,则返回剩余小时的总天数,如果两个日期时间字段之间的日期小于60则剩余分钟。
So far I have managed to show the total number of minutes as days, hours, and minutes:
到目前为止,我已设法将分钟总数显示为天,小时和分钟:
local numbervar tm := datediff('n',{table.date1},{table.date2},0);
local numbervar h := truncate(tm/60,0);
local numbervar d := truncate(tm/1440,0);
local stringvar tm_d := totext(d,0,"") + ' days ';
local stringvar tm_h := totext(h,0,"") + ' hours ';
local stringvar tm_m := totext(tm,0,"") + ' minutes ';
local stringvar tm_string := tm_d & tm_h & tm_m
Returns: 183 days 4393 hours 263633 minutes
返回:183天4393小时263633分钟
183 days which is = to 4393 hours which is = to 263633 minutes
183天= 4393小时= 263633分钟
What I need it to do is show 183 days (not rounded) and any remaining hours (not rounded) and any remaining minutes (not rounded) so it looks something like this:
我需要它做的是显示183天(不是四舍五入)和任何剩余小时(不是四舍五入)和任何剩余的分钟(不是四舍五入)所以它看起来像这样:
The difference between table.date1 and table.date2 is:
table.date1和table.date2之间的区别是:
183 days 4 hours 23 minutes (just used random hours and minutes)
183天4小时23分钟(仅使用随机小时和分钟)
2 个解决方案
#1
Just try this also.
试试吧。
local numbervar tt := datediff('n',{table.DATE1},{table.DATE2});
local numbervar d := truncate(tt/1440,0);
local numbervar h := truncate(remainder(tt,1440)/60,0);
local numbervar m := truncate(remainder(tt,60),0);
local stringvar tt_d := if d=0 then "" else totext(d,0,"") + 'd ';
local stringvar tt_h := if h = 0 then "" else (totext(h,0,"")) + 'h ';
local stringvar tt_m := totext(m,0,"") + 'm ';
local stringvar tt_string := tt_d & tt_h & tt_m
Refer links :
参考链接:
http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=15879
http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=10279
http://www.experts-exchange.com/Database/Reporting/Crystal_Reports/Q_24014196.html
#2
Have no experience with your system, but definitely you'll need this:
没有您的系统经验,但绝对你需要这个:
totalMinutes = 263633
days = floor (totalMinutes /(24*60))
hours = floor (totalMinutes %(24 * 60) /(60))
minutes = floor (totalMinutes % 60)
where % is MOD (ex: 15 MOD 4 = 3)
as far as I see, floor
is same as truncate
, and quick lookup gave, that MOD is MOD
like A MOD B
据我所知,floor与truncate相同,快速查找给出了MOD就像MOD B一样的MOD
#1
Just try this also.
试试吧。
local numbervar tt := datediff('n',{table.DATE1},{table.DATE2});
local numbervar d := truncate(tt/1440,0);
local numbervar h := truncate(remainder(tt,1440)/60,0);
local numbervar m := truncate(remainder(tt,60),0);
local stringvar tt_d := if d=0 then "" else totext(d,0,"") + 'd ';
local stringvar tt_h := if h = 0 then "" else (totext(h,0,"")) + 'h ';
local stringvar tt_m := totext(m,0,"") + 'm ';
local stringvar tt_string := tt_d & tt_h & tt_m
Refer links :
参考链接:
http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=15879
http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=10279
http://www.experts-exchange.com/Database/Reporting/Crystal_Reports/Q_24014196.html
#2
Have no experience with your system, but definitely you'll need this:
没有您的系统经验,但绝对你需要这个:
totalMinutes = 263633
days = floor (totalMinutes /(24*60))
hours = floor (totalMinutes %(24 * 60) /(60))
minutes = floor (totalMinutes % 60)
where % is MOD (ex: 15 MOD 4 = 3)
as far as I see, floor
is same as truncate
, and quick lookup gave, that MOD is MOD
like A MOD B
据我所知,floor与truncate相同,快速查找给出了MOD就像MOD B一样的MOD