计算时间和日期差异(Calculating Time and Date difference)

我目前正在编写一份报告来计算iReport中两个日期变量之间的TotalTimeDifference

我正在比较的两个变量是MO_DATECREATEDMO_DATECOMPLETED并且我试图只计算时间差。

我曾尝试设置一个变量,对两个变量进行简单的减法 - 当然,这根本没有奏效。

我会附上我目前拥有的照片,但我正在寻找比较两个变量(包含日期/时间)和打印出时间差异变量的方式。

例如:如果MO started at 1/2/15 12:55pmcompleted at 1/3/15 1:55pm我想打印时间差或花费多少时间为25 hours

我如何在iReport中做到这一点? 感谢您帮助新手!

我的问题我的报告

编辑答案后,我想展示的日子:


I am currently writing a report to calculate the TotalTimeDifference between two date variables in iReport.

The two variables that I am comparing are MO_DATECREATED and MO_DATECOMPLETED and I am trying to calculate the time difference only.

I have tried setting up a variable that does a simple subtraction of the two variables- and of course that has not worked at all.

I will attach photoes of what I currently have but I am looking for the way to compare the two variables (which contains date/time) and printing out a variables with the difference in time.

Example: If the MO was started at 1/2/15 12:55pm and completed at 1/3/15 1:55pm i want to print the time difference, or how long it took, as 25 hours

How can I do this in iReport? Thank you for helping out a newbie!

My problem MyReport

EDIT After answer, I would like to the show days to:


原文:https://stackoverflow.com/questions/34661493
2024-04-25 17:04

满意答案

你可以这样做:

$(".user").click(function () {
    // Hide it but only if not hidden - hide
    $('.trigger:visible').hide();

    // Later in the script - Show it but only If it's not visible.  
    $('.trigger:hidden').show();
});

对于更多的上下文,在下列情况下元素被视为“隐藏”:

  • 它们的CSS显示值为none。
  • 它们是type =“hidden”的表单元素。
  • 它们的宽度和高度显式设置为0。
  • 或者祖先元素被隐藏,所以元素不会显示在页面上。

此外,“具有可见性的元素:隐藏或不透明度:0被认为是可见的。”

来源: https//api.jquery.com/hidden-selector


You can do this:

$(".user").click(function () {
    // Hide it but only if not hidden - hide
    $('.trigger:visible').hide();

    // Later in the script - Show it but only If it's not visible.  
    $('.trigger:hidden').show();
});

For some more context, elements are deemed ":hidden" if:

  • They have a CSS display value of none.
  • They are form elements with type="hidden".
  • Their width and height are explicitly set to 0.
  • Or an ancestor element is hidden, so the element is not shown on the page.

Additionally, "elements with visibility: hidden or opacity: 0 are considered to be visible."

Source: https://api.jquery.com/hidden-selector

相关问答

更多

jQuery:在可见时自动隐藏通知(jQuery: Auto-hide notification when it's visible)

它实际上非常简单: $(".message").hide().first().show(); setTimeout(showNotifications, 5000); function showNotifications(){ $(".message:visible").remove(); $(".message").first()show(); if($(".message").length > 0){ setTimeout(showNotificatio...

jQuery是(':visible')是(':hidden')没有按预期工作(jQuery is(':visible') is(':hidden') not working as expected)

由于显示正在更新,您可以在功能中检查它,如下所示: if(type === 'user' && action === 'add') { if($('.closeAdd').css("display") == 'none') { $('.closeAdd').show(); } } else { if($('.closeAdd').css("display") == 'block') { $('.closeAdd').hide(); } } Since ...

为什么jQuery显示/隐藏使用display:none而不是visibility:hidden?(Why does jQuery show/hide use display:none instead of visibility:hidden?)

因为在display:none ,为了所有目的,该元素不再存在 - 它不占用任何空间。 然而,在visibility:hidden ,就好像你刚刚添加了opacity:0到元素 - 它占用相同的空间,但只是行为隐形。 jQuery创建者可能认为前者将更适合于.hide() 。 Because in display:none, the element, for all purposes, ceases to exist -- it doesn't occupy any space. However,...

jquery在没有硬编码的情况下显示/隐藏div中的内容(jquery show/hide content in div without hardcoding)

鉴于所有三个都有一个共同的类mox ,并且如果你为每个内容div添加一个公共类content ,你可以这样做: $(".mox").click(function() { $(this).children(".content").show(); $(".mox").not(this).children(".content").hide(); } 说明:每当您单击具有mox类的任何元素时,都会调用该函数。 this选择器允许你选择被单击的类的特定实例, children()选择任何子...

jQuery显示隐藏的li元素,但随后隐藏了可见的li元素(jQuery show hidden li elements, but then hide visible li elements)

见: http : //jsfiddle.net/g9L9R/7/ $('ul') .find('li:gt(2)') .hide() .end() .append( $('<li>Show more...</li>').click( function(){ $(this).siblings().toggle(500); }) );​ 你会在这里得到一个很好的切换效果...... See this: http://jsfiddle.net/g9L9R/7/ $('ul') .find('...

默认情况下隐藏叠加层时,jquery库不可见(jquery gallery not visible when overlay is hidden by default)

您可以只使用一个叠加<div>并在点击时更改background , z-index和content ,例如使用toggleClass 。 我稍微更改了你的代码,所以你有一个工作示例http://codepen.io/anon/pen/vKKJEq You could do just one overlay <div> and change background, z-index and content of it on click, with toggleClass for example. I...

jQuery:手风琴 - 如果隐藏,显示,否则隐藏?(jQuery: Accordion - if hidden, show, else hide?)

代替 .. $(".accordion-content:hidden") 做: $(".accordion-content").is(':hidden') 因为你使用“else”,所以真的不需要最后的“可见”选项。 但如果你想使用它,那么: $(".accordion-content").is(':visible') Instead of .. $(".accordion-content:hidden") Do: $(".accordion-content").is(':hidden') ...

只有在可见的情况下,jQuery才会隐藏,仅在隐藏时才显示[closed](jQuery hide only if visible, show only if hidden [closed])

你可以这样做: $(".user").click(function () { // Hide it but only if not hidden - hide $('.trigger:visible').hide(); // Later in the script - Show it but only If it's not visible. $('.trigger:hidden').show(); }); 对于更多的上下文,在下列情况下元素被视为“隐藏”:...

jQuery - 只隐藏那些可见的(jQuery - Hiding only those that are visible)

使用: .is(':visible')将显示可见的 $(".poi-hover").on( { mouseenter: function() { //$(".poi-hover").css('opacity', 0.2); $('.poi-hover:visible').not(this).css('opacity', 0.2); $(".button_pannel").css('opa...

Jquery显示/隐藏修复[关闭](Jquery show / hide fix [closed])

您不需要绑定两次单击,而是可以将条件显示和隐藏。 $('.plus').click(function(){ if($('#top').is(':visible') $('#top').hide('slow'); else $('#top').show('slow'); }); 您还可以使用toogle活动 $('.plus').toggle(function(){ $('#top').show('slow'); }, ...

相关文章

更多

Real-Time Rendering 笔记 --- 1-4章

里面有些公式和矩阵无法在电脑上书写, 故用纸笔记录了一些笔记, 比如公式的推算, 注意要点等. 由于电 ...

Java日期时间

Java 日期时间 java.util包提供了Date类来封装当前的日期和时间。 Date类提供 ...

在java.util.Date中,如何比较两个Date的大小,精确到分

如题。。麻烦给位了 问题补充:是的哦 renpeng301 写道 晕看来理 ...

用SimpleDateFormat把字符串转换成Date的时候报NumberFormatException

今天用for循环产生多条线程去缓存里面取数据,数据就是字符串形式的日期,我如果用for循环连续的产生线 ...

display控件格式化时间日期的问题?

&lt;display:column property=&quot;f_time&quot; titl ...

日期和时间的国际化

DateFormat 类可以将一个日期/时间对象格式化为表示某个国家地区的日期/时间字符串。 Dat ...

JFreeChart笔记 (十) 时间序列图:差异对比图

公司的新项目开始了,现在每天都得加班到晚上九点以后。难道加班是每个程序猿的宿命?整天累的跟个孙子似的就 ...

Javascript取当前日期、时间、星期的代码

Javascript取当前日期、时间、星期的代码:myDate.getYear(); // 获取当前 ...

java计算某天与今天相差的天数

java计算某天与今天相差的天数 当天使用Calendar.getInstance(),日期传入的是y ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本