SQL to generate the intervals from date of 6 months each, between two date ranges
Hi allI looked in the forums, if someone uses CREATE_CHUNKS_BY_SQL for dates, but no luck.
I want to update a table using pieces of dates.
I need to generate date ranges to divide them by pieces.
I have a table where I know that max (sales_date) and min (sales_date).
Lets say max (sales_date): min (sales_date) 01/01/2008: 31/10/2010
I want to break in intervals of 6 months (180 days) as below:
chunk_id start_date end_date
-------- ---------- --------
1 01/01/2008 06/30/2008
2 01/07/2008 12/31/2008
3 01/01/2009 06/30/2009
4 01/07/2009 12/31/2009
5 01/01/2010 06/30/2010
6 01/07/2010 10/31/2010
He didn't exactly finish end of the month. Basically, I need these beaches of dates at apart 180 days.I appreciate if someone can throw some ideas on this.
Thank you
Raj.
Hi, Raj,
Sorry, it is unclear what you are asking.
To generate a list of dates starting with min_sales_date and including all the 180 days after that up to (but not beyond) max_sales_date:
WITH got_params AS
(
SELECT DATE '2008-01-01' AS min_sales_date
, DATE '2010-10-31' AS max_sales_date
FROM dual
)
SELECT min_sales_date + (180 * (LEVEL - 1)) AS grp_start_date
FROM got_params
CONNECT BY LEVEL <= CEIL ( ( (max_sales_date - min_sales_date)
+ 1
)
/ 180
)
;
Output:
GRP_START_D
-----------
01-Jan-2008
29-Jun-2008
26-Dec-2008
24-Jun-2009
21-Dec-2009
19-Jun-2010
December 16, 2010 is 180 days after June 19, 2010, but it is not displayed, because is after max_sales_date, which is 31 October 2010.
I hope this helps you.
Whenever you have any questions, post a small example of data (CREATE TABLE and INSERT statements) and the results desired from these data.
Tags: Database
Similar Questions
-
SQL to generate the last weeks date (not a stored procedure)
I need SQL to generate the last dates of weeks from Monday to Sunday. I don't want to use the data in the table or the stored procedure. I need inline SQL. Please help me with your suggestions. Thanks in advance for the help.Varun says:
I need SQL to generate the last dates of weeks from Monday to Sunday. I don't want to use the data in the table or the stored procedure. I need inline SQL. Please help me with your suggestions. Thanks in advance for the help.below should help you get started
1* SELECT SYSDATE-LEVEL from dual CONNECT BY LEVEL < 8 SQL> / SYSDATE-L --------- 21-APR-13 20-APR-13 19-APR-13 18-APR-13 17-APR-13 16-APR-13 15-APR-13 7 rows selected.
-
SQL query for the set of data rows not values
Hello!
I use Oracle 10 g (10.2.0.1.0) and I need help to solve this difficult task. I have a huge table with more than 145000 records and I shows you only a sample of it:
ID TEAMNAME_EN DT TEAMNAME_EN HPROB AM APROB FT
324813 31/8 / 2012 DEN HAAG GRONINGEN 1.90 3.30 3.10 2
324823 31/8 / 2012 MAINZ GREUTHER FÜRTH 1.75 3.25 3.65 2
324805 31/8 / 2012 GAZELEC DIJON 1.60 3.15 4.75 1
324810 31/8 / 2012 ÖREBRO DJURGÅRDEN 2.80 3.25 2 2.05
324795 31/8 / 2012 FC KÖLN COTTBUS 1.85 3.20 3.35 2
324837 31/8 / 2012 PORTLAND WOOD COLORADO RAPIDS 2,00 3.20 2.95 1
324828 31/8 / 2012 DROGHEDA UNITED, DUNDALK 1.45 3.65 5.25 1
324827 31/8 / 2012 CORK CITY SHAMROCK ROVERS 3,30 3,80 1.70 2
324833 31/8 / 2012 BARUERI ASA 2.45 3.20 1-2.30
324798 31/8 / 2012 GENÇLERBIRLIGI ORDUSPOR'A 2.00 3,10 X 3.00
324814 31/8 / 2012 ALMERE CITY FC OSS 1,80 3,50 3,20 2
324830 31/8 / 2012 CRICIÚMA BRAGANTINO 1.25 4.35 1 8.00
324820 31/8 / 2012 VOLENDAM FC EINDHOVEN 1.80 3.25 3.45 1
324818 31/8 / 2012 MVV MAASTRICHT TELSTAR 1.40 4.00 X 5.25
324819 31/8 / 2012 DORDRECHT VEENDAM 1.80 3.25 3.45 1
324834 31/8 / 2012 CEARÁ GUARATINGUETÁ 1.40 3.85 X 5.50
If this table consists of
dates
teams (hometeam, awayteam)
numbers for homewin, shoot, awaywin probability
and the final result as 1, X, 2
What I want is a sql query that returns to me for each hometeam, awayteam and (if possible in a single line)
all documents of the hometeam which had the same number of prior probability. For example:
CEARÁ (last line), I would like to the sql to show me all the records of CEARA who had _1.40 3.85 or 5.50_ in each of the three issues of probability, BUT the problem is that I do want separate lines... I can do so far is to calculate a sum of House probability, probability of drawing, close probability for each team but the same records are calculated again in each game of probability!
This means if CEARÁ has 1.40-3.85-5.50 in the past it will return me this line only once, and not 3 times (one for each set of probability)
I hope that I've done my duty,
Thank you for your time and lights
N. SaridakisIs that what you are looking for:
select hometeam, awayteam, hw, hd, hl from (select hometeam, awayteam, ft, SUM(CASE ft WHEN '1' THEN 1 ELSE 0 END) OVER (PARTITION BY hometeam) hw, SUM(CASE ft WHEN 'X' THEN 1 ELSE 0 END) OVER (PARTITION BY hometeam) hd, SUM(CASE ft WHEN '2' THEN 1 ELSE 0 END) OVER (PARTITION BY hometeam) hl from plays) where ft is null
-
Generate the schema from database
Hello:
Version 3.0.0, build 653, which is 3.0 ai2 if I have the right name. Come help - about version information.
We did something in the designer and I would do the same in SQL Data Modeler, it is possible, or use a workaround to a minimum. It is something we absolutely must have before crossing the designer DM.
We receive sets of customer data and import them into a schema. We then open a Designer session, tables we have made DDL changes for some time, click on generate, choose the target containing up-to-date data schema, but old DDL and then click OK to merge the latest repository DDL changes in the schema with the new data but old DDL.
Here's what I know how to do now. I captured the ddl DM Designer with success. I also captured the schema of the database with customer data fresh successfully DM. I think I'm pretty close. I was also able to compare and see the DDL differences using tools - model comparison/merging of views. The problem is that when I click on the DOF preview at the bottom of the dialog box to compare, one containing the differences found, the button pulls up to the DDL file editor dialog box but it is empty/Virgin. So my question to point how do I get a ddl file so I can run it against my client target data schema? I guess that the direct method, I have noted above is therefore more an option, because I read in a post here somewhere.
The output of compare models also includes the differences with the names of the constraints generated by the control system, which will always be different between us and our customers. We don't care merge these names of check constraint and want to exclude the ddl file switch off. Is there a way?
Thanks for any help.
Love this new product so far. Excellent work.
DocDoc,
Thanks for your comments.
Problem with DDLSelection.local is fixed, the fix was a few minutes later to enter in 653.
Compare maps - window is empty because you have not defined mappings.Philippe
-
Windows Backup & restore leaves gaps in the backup period date ranges
I noticed that backup & restore leaves gaps in the date ranges displayed on the screen of backup periods under the function to manage the space. This means that files change during the interval periods have not been saved? For example, the screen shows currently backups and the following periods:
Jan 26: 12-18 Mar, 12 GB 10.40
Apr 04, 12-13 Apr, 12 GB 19.62
27 April, 12-27 Apr, 12 GB 05.16
May 06,12 - May 06,12 02.41 GB
May 27.12 - 17 Jun, 12 GB 03.41
What is the importance of gaps?
How can I tell that B & R is fully backup all files that changed since the last backup run?
How can I varify the 1st backup is a backup full?
How can I varify that the system image backup is up-to-date?
I save approximately once a week to a USB external hard drive. I use options "Include a system image" and "Let me choose" to select the files and have selected the option 'keep only the last frame system & minimize the space used '.
Hello
Backups are created in sets called backup periods. To maximize your disk space, Windows backup backup all folders selected, the first time it's run and then it only backs up files that are new or have been modified since the last backup was made. Periodically, Windows creates a new, full backup. Each full backup is called in a backup. When you view your backups of files, you can see all the backup periods with date ranges. If you decide to delete backups of files, you should always keep the most recent backup of the file.
Reference:
Should what backup settings I use to maximize my disk space? http://Windows.Microsoft.com/en-us/Windows7/what-backup-settings-should-I-use-to-maximize-my-disk-space
Back up and restore: frequently asked questions
http://Windows.Microsoft.com/en-us/Windows7/products/features/backup-and-restore
-
I want to bridge.and wireless I can't do that... Please send me how to write to a wireless bridge between two different routers.
1:broadbandand2:Dlink dir 605 l,Hi Mohammed Ehsan Jourah,.
Thanks for posting the request in the Microsoft community forums.
I understand that you need to know how to make a wireless bridge between two different routersWhat version of the operating system is installed on the computer?
To connect multiple computers, install a network adapter in each and run a network CAT5 cabling to connect each one to a hub (and thus the other.) The computer that will serve as a transition will have a standard network card for wired and a wireless network adapter that will connect to the wireless (WAP) access point or gateway on the second network.
A network bridge is software or hardware that connects two networks or more so that they can communicate. You can create only a single bridge network on a computer, but a bridge can handle any number of network connections.
You can try the steps at the bridge between two different routers wireless.
a. determine the coverage area. When using two or more routers, the coverage area should be divided, and each router should be placed in a central location in each subdivision. If you add a wireless router to an existing network, this may mean moving the first router.
b. decide which router is the main router. The main router is connected to the Internet, a LAN cable or other networks. It should be as close to the wired network connections or who has the best line of sight to another wireless network. In addition, the main router should be a high range router, allowing large tables of State and more users.
c. buy a spare antenna, as the antennas that come with most routers do not have very good range. Quality omnidirectional antennas can push the range and signal strength of each of the routers, which, in turn, will reduce the cost by allowing routers less cover more space overall.
d. deploy the primary router carefully. This router is the most important and requires most of the time of installation and options. Set the WEP (Protocol) encryption Service Set Identifier (SSID) and wireless, set up the Internet connection and test the router with some clients (computers). Once you get the main router deployed, deploy other routers should be easy.
e. deploy the secondary routers, which must be configured to operate in "mode of transition." Secondary routers should be deployed around the perimeter of a large area or 'hot spots' where users placed - for example, will convene a bench Park or the table.Links:
Create a network bridge:
http://Windows.Microsoft.com/en-us/Windows7/create-a-network-bridgeAdd a connection to a network bridge:
http://Windows.Microsoft.com/en-us/Windows7/add-a-connection-to-a-network-bridgeHope this information helps you. If you need to get help or information with decision-making wireless bridge between two different routers, I'll be happy to help you.
-
pl/sql block, reading the reading of data from the table to a single point in time
I'm trying to figure out if several cursors in a PL/SQL block are executed inside a single Point in time, and so don't see no updates of paintings by other processes or procedures running at the same time.
The reason why I ask is I have a block of code as an initial extraction of data, with some Sanity Check before the code runs. However, if another procedure might modify the data between the two, then the mental health check is not valid. So I am essentially trying to know if there is consistency read in a PL/SQL, preventing updates to other processes to be seen.
Anyone who has an idea?
BR,
ChambazGoogle SET Transaction.
or
Follow this link
http://download-West.Oracle.com/docs/CD/B12037_01/server.101/b10759/statements_10005.htm
Kind regards
Prazy -
Rename the file from data in a table only displays error
Hi, I was looking to move the data from one place to another location file.
I issues a command as follows:
When I start thw query select b.SID:
Select b.SID, b.name
v $ tablespace a, v$ datafile b
where a.ts #= b.ts #;
It shows all storage spaces and their data files. No problem there.
Then I did the following:
My storage space is meddata, first I took it to offline.
alter tablespace offline normal meddata;
Then I made the command:
alter tablespace meddata rename
alter tablespace rename datafile meddata ' E:\MEDDATA\MEDDATA01. DBF'
to ' D:\ORACLE112\ORADATA\ORCL\MEDDATA01. DBF';
But the following error message:
SQL > alter tablespace rename datafile meddata ' E:\MEDDATA\MEDDATA01. DBF'
2 to ' D:\ORACLE112\ORADATA\ORCL\MEDDATA01. DBF';
alter tablespace rename datafile meddata ' E:\MEDDATA\MEDDATA01. DBF'
*
ERROR on line 1:
ORA-01525: Error renaming data files
ORA-01141: Error renaming file 14 - new data file ' D:\ORACLE112\ORADATA\ORCL\MEDDATA01. DBF' not raise
d
ORA-01110: data file 14: ' E:\MEDDATA\MEDDATA01. DBF'
ORA-27047: cannot read file header block
OSD-04006: ReadFile() failure, unable to read the file
S/O-error: (OS 38) at the end of the file.
Can not understand what's wrong here. Help, please.
Hasan Al Mamun
Hello
After taking the tablespace offline, manually copy you the file E: D:\ORACLE112\ORADATA\ORCL\ loction location? You must manually copy the data file and then execute alter tablespace rename datafile and then recover tablespace and put online.
Anand
-
function/SQL to get the next weekend date of SUNDAY, in light of the current sysdate
Hi all
someone at - it a reliable piece of SQL or the function that takes the current SYSDATE as a parameter and returns the next date available weekend (SUNDAY)
So for example if it is adopted as of today 01/07/2009 (Wednesday) it returns data 07/05/2009, which is the Date of Sunday following.
Even if I went to Sunday 07/05/2009, it would go back the date 07/12/2009, which is this Sunday.
Any help in advance apppreciated!
Kind regards
Satnamselect next_day(sysdate, 'SUNDAY') from dual
Good luck
-
prevent sql injection in the transition from input parameter
Dear expert;
I was advice not not programmed that way due to the fact, it could cause a SQL injection. Therefore, what is the alternative for below. It must be a function that returns a ref cursor See my below syntax
any help is appreciated. Thank you.create or replace package test as type list_cur is ref cursor; function lists_needed(p_class varchar2) return list_cur; end test; create or replace package body test as function lists_needed(p_class varchar2) return list_cur is my_list_cur list_cur; begin open my_list_cur for select id from tbl_one t where t.id like (p_class) || %; return my_list_cur; end lists_needed; end test;
SQL injection requires a dynamic code. I don't see how it could happen in this code or the example in your other thread.
-
Problem with the creation of date range with PL/SQL WHERE clause
Hello, everyone:
I'm unable to develop and the SQL statement to filter records today and seven days back. My condition is as follows:
I think I'm to mess with the (to_char (ALM_OG_ACTIVITY_DATE, ' mm/dd/yyyy ' ")) statement.from wsualumni.wsu_online_giving_table --where ALM_OG_ACTIVITY_DATE >= ALM_OG_ACTIVITY_DATE - 7 where ALM_OG_ACTIVITY_DATE >= SYSDATE - 7 and ALM_OG_CAMPAIGN_CODE = 'MED' OR ALM_OG_CAMPAIGN_CODE = 'MED1';
The actual code is below to:
Resultsset serveroutput ON SIZE 1000000 set heading off set feedback off set trimspool off set echo off set pagesize 0 DECLARE v_data_line_hdr varchar2(1000); v_data_file varchar2(80); v_sch_code varchar2(10); v_instance_name varchar2(10); ws_path payroll.pybutfl.pybutfl_utl_file_path%TYPE; v_data_line VARCHAR2 (4000) := NULL; fhandle_o UTL_FILE.file_type; v_line_count NUMBER := 0; v_selected_count NUMBER := 0; v_error_count NUMBER := 0; v_written_count NUMBER := 0; v_error_text VARCHAR2 (50) := ' Unable to write the line. '; v_errm VARCHAR2 (255); v_sqlerrm VARCHAR2 (255); CURSOR C1 IS select RTRIM ( ALM_OG_ID ||'|'|| NULL ||'|'|| (to_char(ALM_OG_AMOUNT, '999,999.99')) ||'|'|| 'Cash' ||'|'|| 'Credit Card' ||'|'|| (to_char(ALM_OG_ACTIVITY_DATE, 'mm/dd/yyyy')) ||'|'|| ALM_OG_ACCI_CODE ||'|'|| 'On-Line Giving' ||'|'|| 'On-Line giving' ||'|'|| ALM_OG_HONOR_MEM_NAME ||'|'|| NULL ||'|'|| 'Do not post' ||'|'|| 'StandardThankYou' ||'|'|| 'Not Acknowledged' ||'|'|| 'Do not receipt' ||'|'|| NULL ||'|'|| 'Banner Gift Number' ||'|'|| ALM_OG_BANNER_GIFT_NO ||'.'|| ALM_OG_ACCI_CODE ||'|'|| (to_char(ALM_OG_ACTIVITY_DATE, 'mm/dd/yyyy')) ||'|'|| NULL ||'|'|| 'Web ID' ||'|'|| ALM_OG_WEBID ||'|'|| NULL ||'|'|| 'Source' ||'|'|| ALM_OG_CAMPAIGN_CODE ||'|'|| 'On-Line Giving' ) data_line from wsualumni.wsu_online_giving_table --where ALM_OG_ACTIVITY_DATE >= ALM_OG_ACTIVITY_DATE - 7 where ALM_OG_ACTIVITY_DATE >= SYSDATE - 7 and ALM_OG_CAMPAIGN_CODE = 'MED' OR ALM_OG_CAMPAIGN_CODE = 'MED1'; CURSOR C2 IS select RTRIM( 'ConsID' ||'|'|| 'GFImpID' ||'|'|| 'GFTAmt' ||'|'|| 'GFType' ||'|'|| 'GFPayMeth' ||'|'|| 'GFDate' ||'|'|| 'FundID' ||'|'|| 'CAMPID' ||'|'|| 'GFAppeal' ||'|'|| 'GfRef' ||'|'|| 'GfPostDate' ||'|'|| 'GfPostStatus' ||'|'|| 'GfltrCode' ||'|'|| 'GfAck' ||'|'|| 'GfRcpt' ||'|'|| 'GfAttrlmpID00' ||'|'|| 'GfAttrCat00' ||'|'|| 'GfAttrdesc00' ||'|'|| 'GfAttrDate00' ||'|'|| 'GfAttrlmpD01' ||'|'|| 'GfAttrCat01' ||'|'|| 'GfAttrdesc01' ||'|'|| 'GfAttrlmpID02' ||'|'|| 'GfAttrCat02' ||'|'|| 'GfAttrdesc02' ||'|'|| 'GfSubType' ) line_header from DUAL; /**********************************************************************/ /* Main Program Processing */ /**********************************************************************/ BEGIN DBMS_OUTPUT.put_line ('Program Started in wsualumni.wsu_online_giving_online'); IF UTL_FILE.is_open (fhandle_o) THEN UTL_FILE.fclose (fhandle_o); END IF; /* Name The File Here */ v_data_file := ('MED_SCH_' || TO_CHAR(sysdate, 'dd-MON-yyyy') || '_OG_DATA.txt'); SELECT RTRIM (pybutfl_utl_file_path) INTO ws_path FROM payroll.pybutfl; fhandle_o := UTL_FILE.fopen (ws_path, v_data_file, 'w'); DBMS_OUTPUT.put_line ('UTLFILE file for this run is: ' || ws_path||'/'||v_data_file); v_written_count := 0; FOR c2_rec IN C2 LOOP BEGIN v_selected_count := v_selected_count + 1; v_data_line_hdr := rtrim(c2_rec.line_header); UTL_FILE.put_line (fhandle_o, v_data_line_hdr); v_written_count := v_written_count + 1; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line (v_error_text); v_error_count := v_error_count + 1; END; END LOOP; FOR c1_rec IN C1 LOOP BEGIN v_selected_count := v_selected_count + 1; v_data_line := rtrim(c1_rec.data_line); UTL_FILE.put_line (fhandle_o, v_data_line); v_written_count := v_written_count + 1; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line (v_error_text); v_error_count := v_error_count + 1; END; END LOOP; DBMS_OUTPUT.put_line ('Number of Records Selected: ' || v_selected_count); DBMS_OUTPUT.put_line ('Number of Records Written: ' || v_written_count); IF UTL_FILE.is_open (fhandle_o) THEN UTL_FILE.fclose (fhandle_o); END IF; END; /
ConsID|GFImpID|GFTAmt|GFType|GFPayMeth|GFDate|FundID|CAMPID|GFAppeal|GfRef|GfPostDate|GfPostStatus|GfltrCode|GfAck|GfRcpt|GfAttrlmpID00|GfAttrCat00|GfAttrdesc00|GfAttrDate00|GfAttrlmpD01|GfAttrCat01|GfAttrdesc01|GfAttrlmpID02|GfAttrCat02|GfAttrdesc02|GfSubType 000013505|| 20.00|Cash|Credit Card|06/22/2009|221686|On-Line Giving|On-Line giving|||Do not post|StandardThankYou|Not Acknowledged|Do not receipt||Banner Gift Number|1179534.221686|06/22/2009||Web ID|000013505||Source|MED|On-Line Giving 000013505|| 20.00|Cash|Credit Card|06/22/2009|770830|On-Line Giving|On-Line giving|||Do not post|StandardThankYou|Not Acknowledged|Do not receipt||Banner Gift Number|1179534.770830|06/22/2009||Web ID|000013505||Source|MED|On-Line Giving
Hello
The problem is due to the "OR" condition (I did not pay attention to it earlier).
Because of this condition, your query is given beyond 7 days recovery. You need to rewrite the code as:
ALM_OG_CAMPAIGN_CODE in ('MED', 'MED1')
Instead of
and ALM_OG_CAMPAIGN_CODE = 'MED' OR ALM_OG_CAMPAIGN_CODE = 'MED1';
This will do the magic for you.
Concerning
Asif Momen
http://momendba.blogspot.com -
Dear all,
Select wo_dt, count (*) "SURRENDER" of twrkordr where
wo_dt > to_date(sysdate-7,'DD-MON-YY') and wo_code_no in (812 820)
Wo_dt group
order of wo_dt
/
Output
ASSIGNMENT OF WO_DT
--------- ----------
4 JANUARY 13 13
JANUARY 5, 13 3
JANUARY 7 13 20
JANUARY 8, 13 9
9 JANUARY 13 10
JANUARY 10, 13 2
Output desired is
Discount
JANUARY 4, 13 5 JANUARY 13 JANUARY 7, 13 JANUARY 8, 13 JANUARY 9, 13 JANUARY 10, 13
13 3 20 9 10 2
Thanks in advance
Ash
-
How to get the number of days in a month of belonging to a range of dates
Hi, I'm going crazy around a problem, I have 2 dates and one month I wanto to retrieve the number of days belonging to the months that fall within the range.
for example:
month of January 2011. begin_date = January 11, 2011, May 30, 2011 end_date result is 21
month of January 2011. begin_date = December 11, 2010, result of end_date, January 10, 2011 10
month January 2011 .begin_date = 2 February 2011, end_date may 25, 2011 result 0
month of January 2011. begin_date = January 3, 2011, January 5, 2011 result DATE END 3
and so on...
I appreciate any suggestion
Thank you
AndreaSomething like that... ?
SQL> with t as 2 (select to_date('11/01/11','dd/mm/yy') from_dt, 3 to_date('30/05/11','dd/mm/yy') to_dt, 4 'Jan-11' mnth from dual) 5 select least(last_day(to_date(mnth,'Mon-yy')),to_dt) - 6 greatest(to_date(mnth,'Mon-yy'),from_dt) cnt 7 from t ; CNT ---------- 20
If 0 is also expected...
SQL> with t as 2 (select to_date('11/01/11','dd/mm/yy') from_dt, 3 to_date('30/05/11','dd/mm/yy') to_dt, 4 'Jan-11' mnth from dual union all 5 select to_date('11/01/11','dd/mm/yy') from_dt, 6 to_date('30/05/11','dd/mm/yy') to_dt, 7 'Jan-12' mnth from dual 8 ) 9 select from_dt,to_dt,mnth, 10 greatest( 11 least(last_day(to_date(mnth,'Mon-yy')),to_dt) 12 - 13 greatest(to_date(mnth,'Mon-yy'),from_dt) 14 ,0) cnt 15 from t; FROM_DT TO_DT MNTH CNT --------- --------- ------ ---------- 11-JAN-11 30-MAY-11 Jan-11 20 11-JAN-11 30-MAY-11 Jan-12 0
Published by: JAC on February 9, 2012 19:22
-
How to get the time in hours minutes and seconds subtraction between two varchar t
Hi all
I have two variable varchar that has a value like this
v_outpunch1: = 17: 50:00'
and v_Shifttime: = 18:00:00 '
This time I'm subtracting here and in another varchar variable
who's like that.
v_EarlyLeaverstimeformat: = ((extrait extrait de (heure de TO_TIMESTAMP (v_ShiftTime, 'HH24:mi:ss'))-(heure de TO_TIMESTAMP (v_OutPunch1, 'HH24:mi:ss') LPAD)), 2, '0'): ': ' |)) LPAD ((extrait (minute de TO_TIMESTAMP (v_ShiftTime, 'HH24:mi:ss'))-extrait (minute de TO_TIMESTAMP (v_OutPunch1, 'HH24:mi:ss'))), 2, '0'): ': ' |)) LPAD ((extrait (seconde de TO_TIMESTAMP (v_ShiftTime, 'HH24:mi:ss'))-extrait (seconde de TO_TIMESTAMP (v_OutPunch1, 'HH24:mi:ss'))), 2, '0');))
It is not properly subtracting value.
Thank youThis works for me...
SQL> ed Wrote file afiedt.buf 1 with t as(select to_date('17:50:00','HH24:MI:SS') as out, to_date('18:00:00','HH24:MI:SS') as shft from dual) 2 -- 3 select to_char(trunc(sysdate)+(shft-out),'HH24:MI:SS') as diff 4* from t SQL> / DIFF -------- 00:10:00
If you want something different, please report the details according to the FAQ: {message identifier: = 9360002}
-
Using SQL to display the date range
Gurus,
I have a sql statement such as
My output looks likeselect MIN(HIREDATE), MAX(HIREDATE) FROM EMP WHERE DEPTNO = 30
Based on the values of MIN (HIREDATE), MAX (HIREDATE) valuesMIN(HIREDATE) MAX(HIREDATE) 12/30/1998 12/30/2001
I need a SQL to generate the output as
30/12/1998
30/01/1999
28/02/1999
---
---
until the Max value (HIREDATE)
In February, we have 30 days, in this case to the last day of the month.
Thanks for the great help
C 007Hello
put my post to correct and others with useful, please
Is salim.
Maybe you are looking for
-
MacBook or iMac? U.K. based
New here so apologies in advance for any injuries I can do! Am about to replace an old MacBook 10 year that works but is so slow I can't take more. I already have an iPad. I mainly use the laptop for word processing, scanning, art stuff, that sort
-
Fan MacBook Pro makes horrible grinding when picked up
I'm worried that my fan is really messed up. Sometimes when I take my laptop it sounds like the fan is hitting something inside my laptop. I also noticed that my laptop heats up as it usually does. Should I bring to the Apple Store? They will fix it
-
I want to hide the task bar, but then, I don't see the system tray. Is it possible to have the separate system tray?
-
HP LaserJet CP1025nw - shortcut or Windows 8 cleaning cleaning Instructions
I have a HP LaserJet CP1025nw, USB to a Vista laptop. I've had for about a year and a half and am well versed in the issues he has with the error of system tray HP resulting in the impossibility to access the device settings to start the cleaning cy
-
How to navigate in one single screen to another?
Hai, I am a beginner in java development. I need to know how to navigate a single screen to another screen. Someone knows it please help me... Thank you cordially dembele