在Perl程序中,我有一个包含这种格式的日期/时间的变量:
Feb 3 12:03:20
Run Code Online (Sandbox Code Playgroud)
我需要确定该日期是否超过x秒(基于当前时间),即使这发生在午夜(例如Feb 3 23:59:00当前时间= Feb 4 00:00:30).
我发现的perl日期/时间信息令人难以置信.我可以告诉我需要使用Date :: Calc,但我找不到秒 - delta.谢谢 :)
下面是我运行的查询,以获取最近一小时的更新.
select count(*)
from my_table
where last_updated_date between to_date(to_char(sysdate,'YYYY-MM-DD HH24'))-1/24 and to_date(to_char(sysdate,'YYYY-MM-DD HH24'));
Run Code Online (Sandbox Code Playgroud)
我们的数据库是oracle,它失败了
ORA-01861: literal does not match format string
01861. 00000 - "literal does not match format string"
*Cause: Literals in the input must be the same length as literals in
the format string (with the exception of leading whitespace). If the
"FX" modifier has been toggled on, the literal must match exactly,
with no extra whitespace.
*Action: Correct the format string to match the literal.
Run Code Online (Sandbox Code Playgroud)
这次失败的原因是什么?
我有一个包含许多变量的页面,这些变量包含一个字符串格式的日期(yyyy-mm-dd),它源自使用moment.js.
有没有办法可以将这样的变量传递给Javascript日期对象resp.将它转换为Javascript日期对象?我对时间不感兴趣,只要我能把日期转换成一个很棒的日期对象.
我尝试了以下但这不起作用,我找不到使用moment.js的方法:
var newVar = new Date(dateVar);
Run Code Online (Sandbox Code Playgroud)
蒂姆,非常感谢你提供的任何帮助.
我有这种格式的约会{Y,M,D}.是否有任何良好的支持库或我可以使用的技巧,简单地说,从这个日期减去三个月而不会遇到无效日期,闰年等问题.
我最近的类似用法是在MySql中你可以输入:
Select '2011-05-31' - Interval 3 Month;
Run Code Online (Sandbox Code Playgroud)
产量'2011-02-28'.我对如何自己编写这个库不感兴趣,这是我想避免的.
我有一组上周创建的记录,从那些我只想检索那些在6h45和1915之间创建的记录.我有一个creation_date我可以使用的专栏.
我怎么能在sql中这样做?
我正在尝试计算Oracle select中两个日期之间的工作日.当我的计算给出给定日期的大多数结果时,我得到了这一点(我将它与excel中的NETWORKDAYS进行比较),但有时它在2天到-2天之间变化 - 我不知道为什么......
这是我的代码:
SELECT
((to_char(CompleteDate,'J') - to_char(InstallDate,'J'))+1) - (((to_char(CompleteDate,'WW')+ (52 * ((to_char(CompleteDate,'YYYY') - to_char(InstallDate,'YYYY'))))) - to_char(InstallDate,'WW'))*2) as BusinessDays
FROM TABLE
Run Code Online (Sandbox Code Playgroud)
谢谢!
我想减去2个日期,并以小时数表示小时和分钟的结果.
我有下表,我这样做,但结果并不理想.
有一些细微的变化,我确信这是简单的算术,但我没有做对.
select start_time, end_time, (end_time-start_time)*24 from
come_leav;
Run Code Online (Sandbox Code Playgroud)
START_TIME END_TIME (END_TIME-START_TIME)*24 ------------------- ------------------- ------------------------ 21-06-2011 14:00:00 21-06-2011 16:55:00 2.9166667 21-06-2011 07:00:00 21-06-2011 16:50:00 9.8333333 21-06-2011 07:20:00 21-06-2011 16:30:00 9.1666667
我想要结果(end_time-start_time)如下.
16:55- 14:00 = 2.55 16:50-07:00 = 9.5 16:30-7:20 = 9.1 and so on.
我怎样才能做到这一点?
我有一个月的金额,我需要在这个月的天数平均分配.数据如下所示:
Month Value
----------- ---------------
01-Jan-2012 100000
01-Feb-2012 121002
01-Mar-2012 123123
01-Apr-2012 118239
Run Code Online (Sandbox Code Playgroud)
我必须将Jan金额超过31天,2月金额超过29天,3月金额超过31天.
如何使用PL/SQL查找月份列中给出的月份中的天数?
例如,我有2个时间表:T1
id time
1 18:12:02
2 18:46:57
3 17:49:44
4 12:19:24
5 11:00:01
6 17:12:45
Run Code Online (Sandbox Code Playgroud)
和T2
id time
1 18:13:02
2 17:46:57
Run Code Online (Sandbox Code Playgroud)
我需要从T1获得与T2时间最接近的时间.这些表之间没有关系.它应该是这样的:
select T1.calldatetime
from T1, T2
where T1.calldatetime between
T2.calldatetime-(
select MIN(ABS(T2.calldatetime-T1.calldatetime))
from T2, T1)
and
T2.calldatetime+(
select MIN(ABS(T2.calldatetime-T1.calldatetime))
from T2, T1)
Run Code Online (Sandbox Code Playgroud)
但我无法得到它.有什么建议?
我需要找到格式为hh:mm:ss的时间之间的差异
select msglog.id,max(msglog.timestamp) enddate,
min(msglog.timestamp) startdate,
enddate - startdate
from MESSAGELOG msglog
group by id
Run Code Online (Sandbox Code Playgroud)
在上面的查询中,msglog.timestamp的类型为DATE.
如何在oracle中以正确的格式获取经过的时间或差异?