date-arithmetic

Calling procedure from oracle to crystal report

允我心安 提交于 2019-12-08 03:56:14
问题 I've created an oracle procedure and it's working on oracle SQL editor. I want to use the procedure in Crystal report. From database expert, I select the procedure and there's an error message: ============================== Query Engine Error: 'ADO Error Code: 0x Source: OraOLEDB Description: ORA-01850: hour must be between 0 and 23 ORA-06512: at "NPLS.PROC_YEARLYACTIVELIST2", line 19 ORA-06512: at line 1 Native Error: ' ============================== I declare the variables like this: =====

Trying to subtract 5 days from a defined date - Google App Script

烂漫一生 提交于 2019-12-08 02:01:36
问题 I'm trying to write a script which is supposed to send out an email and create two calender entries when submitting a form. To be honest, this is my first script and I am very happy that the email is send out and the calender entries are working as well. The thing which gives me a headache is to subtract 5 days (actually x days) from a defined date. First I thought I could simply do something like var liveday = e.values[2]; var newday = liveday-5; well, this didn't work :-) I tried more: var

Daily average for the month (needs number of days in month)

孤人 提交于 2019-12-07 14:48:32
问题 I have a table as follow: CREATE TABLE counts ( T TIMESTAMP NOT NULL, C INTEGER NOT NULL ); I create the following views from it: CREATE VIEW micounts AS SELECT DATE_TRUNC('minute',t) AS t,SUM(c) AS c FROM counts GROUP BY 1; CREATE VIEW hrcounts AS SELECT DATE_TRUNC('hour',t) AS t,SUM(c) AS c,SUM(c)/60 AS a FROM micounts GROUP BY 1; CREATE VIEW dycounts AS SELECT DATE_TRUNC('day',t) AS t,SUM(c) AS c,SUM(c)/24 AS a FROM hrcounts GROUP BY 1; The problem now comes in when I want to create the

Subtracting n Days from a date using SQL

谁说我不能喝 提交于 2019-12-07 11:21:08
问题 I am quite a beginner when it comes to Oracle. I am having trouble figuring out how to do something similar to this : SELECT ID, NAME, TO_CHAR(DATEBIRTH, 'DD/MM/YYYY HH24:MI:SS') FROM PEOPLE WHERE DATEBIRTH >= ANOTHERDATE - NDAY To put it short, I want to select everyone who were born N days before a specific date and time but I am not quite sure that this is the way to do it nor that it would give me the results I expect. PS: I am developping under oracle8i. 回答1: Your query looks correct to

SQL date conversion results to “invalid number format model parameter.”

戏子无情 提交于 2019-12-07 07:28:57
问题 I have to select some data from Oracle 11g database, but I can't seem to figure out why following select query is failing: SELECT INFO_ID, INFO_DETAIL, IMPORTANT_FLG, DELETE_FLG, CREATE_TIME, DISPLAY_ORDER FROM TABLE_NAME WHERE TO_DATE(TO_CHAR(CREATE_TIME, 'YYYY/MM/DD'), 'YYYY/MM/DD') BETWEEN TO_DATE(TO_CHAR(:fromDate, 'YYYY/MM/DD'), 'YYYY/MM/DD') AND TO_DATE(TO_CHAR(:toDate, 'YYYY/MM/DD'), 'YYYY/MM/DD') ORDER BY IMPORTANT_FLG DESC NULLS LAST , DISPLAY_ORDER ASC NULLS LAST, CREATE_TIME DESC,

Fill in missing year in ordered list of dates

天大地大妈咪最大 提交于 2019-12-07 06:34:51
问题 I have collected some time series data from the web and the timestamp that I got looks like below. 24 Jun 21 Mar 20 Jan 10 Dec 20 Jun 20 Jan 10 Dec ... The interesting part is that the year is missing in the data, however, all the records are ordered, and you can infer the year from the record and fill in the missing data. So the data after imputing should be like this: 24 Jun 2014 21 Mar 2014 20 Jan 2014 10 Dec 2013 20 Jun 2013 20 Jan 2013 10 Dec 2012 ... Before lifting my sleeves and start

Difference in time between records

百般思念 提交于 2019-12-07 04:48:13
问题 I have a table that has (among others) a timestamp column (named timestamp; it's a standard Oracle DATE datatype). The records are about 4-11 minutes apart, about 7 or 8 records every hour, and I'm trying to determine if there is any pattern to them. Is there an easy way to see each record, and the number of minutes that record occurred after the previous record? Thanks, AndyDan 回答1: This is Oracle 9i+, using the LAG function to get the previous timestamp value without needing to self join:

Trying to subtract 5 days from a defined date - Google App Script

喜欢而已 提交于 2019-12-06 12:32:46
I'm trying to write a script which is supposed to send out an email and create two calender entries when submitting a form. To be honest, this is my first script and I am very happy that the email is send out and the calender entries are working as well. The thing which gives me a headache is to subtract 5 days (actually x days) from a defined date. First I thought I could simply do something like var liveday = e.values[2]; var newday = liveday-5; well, this didn't work :-) I tried more: var newtime = new Date(liveday); var yr = newtime.getYear(); var dt = newtime.getDay(); var mt = newtime

How to calculate time difference between datetimes, for each group (student-contract)?

偶尔善良 提交于 2019-12-06 08:28:53
I have a specific problem; I have data in the following format: # USER_ID SUBMISSION_DATE CONTRACT_REF 1 1 20/6 1:00 W001 2 1 20/6 2:00 W002 3 1 20/6 3:30 W003 4 4 20/6 4:00 W004 5 5 20/6 5:00 W005 6 5 20/6 6:00 W006 7 7 20/6 7:00 W007 8 7 20/6 8:00 W008 9 7 20/6 9:00 W009 10 7 20/6 10:00 W0010 Now I need to somehow calculate the time difference between the different submissions (uniquely identifiable). In other words: I have a table of submissions , in this table, there are all submissions for all users. I need to find a way how to calculate the time difference for each unique STUDENT

How to create a datetime from parts in Oracle/PLSQL?

安稳与你 提交于 2019-12-06 03:12:17
I have a date (4/30/2012), an hour (4) and a minute (45). I need to convert that to an Oracle datetime value for comparison in a PLSQL/Oracle SELECT statement. Ideally, there would be a function like this (C# since I know it a little better): var date = "4/30/2012"; var hour = "4"; var minute = "45"; DateTime myDateTime = convertDateTime(date, hour, minute); I have a table with three columns to make up the date and time of an event. I have another table that has items that may or may not match based on their start and end dates. In pseudo SQL, here's what I'm trying to do: SELECT G.Name,