find the 3rd Friday of the month at a given date
How can 3rd Friday of the month at a given date? I can always spend the first day of the month as inputfor example, the effective date is 1 January 09. need to get the 3rd Saturday 16 January 09 (Jan has 5 Friday 02, 09, 16,23,30)
entry date: 1 February 09, needed 20 February 09
Published by: user520824 on April 1st, 2009 12:30
How about you...
select trunc(sysdate,'mm') + (6 - to_char(trunc(sysdate,'mm'),'d')) + 14 from dual;
TRUNC(SYS
---------
17-APR-09
select trunc(to_date('01-JAN-09'),'mm') + (6 - to_char(trunc(to_date('01-JAN-09'),'mm'),'d')) + 14 from dual;
TRUNC(TO_
---------
16-JAN-09
select trunc(to_date('01-FEB-09'),'mm') + (6 - to_char(trunc(to_date('01-FEB-09'),'mm'),'d')) + 14 from dual;
TRUNC(TO_
---------
20-FEB-09
select trunc(to_date('01-MAR-09'),'mm') + (6 - to_char(trunc(to_date('01-MAR-09'),'mm'),'d')) + 14 from dual;
TRUNC(TO_
---------
20-MAR-09
Tags: Database
Similar Questions
-
Select the first 20 days of the month for a given date
Hi gurus,
Please let me know to select the first 20 dates for a date supplied by using a parameter.
For ex -.
Suppose I provided a date by using a parameter - January 13, 2012
The query should return me - 01-Jan-2012, January 2, 2012... January 20, 2012
or if I get home on 23 March 2012
The query should return me - 01-Mar-2012, March 2, 2012... 20 March 2012
Thanks in advance.Hello
Here's one way:
VARIABLE target_date VARCHAR2 (11) EXEC :target_date := '13-Jan-2012'; SELECT TO_DATE ( SUBSTR (:target_date, 4) , 'Mon-YYYY' ) + LEVEL - 1 AS a_date FROM dual CONNECT BY LEVEL <= 20 ;
Note that this does not take account the part of: target_date that represents the day of the month. When you use TO_DATE without giving a date of the month, it defaults to the 1st of the month.
-
where can I find the monthly subscription?
where can I find the monthly subscription?
Hey julietteh55830290,
Before include files, make sure that they have been converted to PDF format.
See this KB doc. Document Cloud Help | Adobe PDF package using.
Kind regards
Nicos
-
To find the months and days between 2 dates
Hello
I want to find the months and days between 2 dates.
For example.
1 - Date: August 25, 2013
2 - Date: October 23, 2013
If we consider each month 30 days, it should give
August 25, 2013 to August 30, 2013 = 6 days
01-Sep-2013-30-Sep-2013 = 1 month
October 23, 2013 to October 30, 2013 = 8 days
Total = 1 month and 14 days.
Kindly help as soon as possible.
Thanks and greetings
Suresh
Assuming that d2 > d1,.
where d)
Select sysdate d1, sysdate + 56 double d2
Union all select to_date (March 1, 2013 ',' dd-mon-yyyy "") d1, to_date (March 31, 2013 ',' dd-mon-yyyy ') d2 double
Union all select to_date (5 February 2013 ',' dd-mon-yyyy ') d1, to_date (March 31, 2013 ',' dd-mon-yyyy "") double d2
Union all select to_date (February 25, 2013 ',' dd-mon-yyyy "") d1, to_date (March 23, 2013 ',' dd-mon-yyyy ') d2 double
Union all select to_date (February 25, 2013 ',' dd-mon-yyyy ') d1, to_date (March 31, 2013 ',' dd-mon-yyyy "") double d2
Union all select to_date (August 2, 2013 ',' dd-mon-yyyy "") d1, to_date (29 October 2013 ',' dd-mon-yyyy ') d2 double
Union all select to_date (February 1, 2013 ',' dd-mon-yyyy "") d1, to_date (May 31, 2013 ',' dd-mon-yyyy ') d2 double
Union all select to_date (25 August 2013 ',' dd-mon-yyyy "") d1, to_date ('03-Sep-2013', 'Mon-dd-yyyy') d2 double
Union all select to_date (July 30, 2013 ',' dd-mon-yyyy "") d1, to_date (August 31, 2013 ',' dd-mon-yyyy ') d2 double
Union all select to_date (July 31, 2013 ',' dd-mon-yyyy ') d1, to_date (August 30, 2013 ',' dd-mon-yyyy "") double d2
Union all select to_date (July 31, 2013 ',' dd-mon-yyyy ') d1, to_date (3 August 2013 ',' dd-mon-yyyy "") double d2
Union all select to_date (3 July 2013 ',' dd-mon-yyyy "") d1, to_date (August 31, 2013 ',' dd-mon-yyyy ') d2 double
Union all select to_date ('31-08-2013', ' dd-mm-yyyy'), to_date('05-10-2013','dd-mm-yyyy') of the double
Union all select to_date ('05-02-2013', ' dd-mm-yyyy'), to_date('31-03-2013','dd-mm-yyyy') of the double
Union all select to_date ('05-02-2013', ' dd-mm-yyyy'), to_date('05-03-2013','dd-mm-yyyy') of the double
Union all select to_date ('05-02-2013', ' dd-mm-yyyy'), to_date('05-02-2013','dd-mm-yyyy') of the double
)
Select d1, d2,
1 + 30 * trunc (months_between (d2, d1)) + LESS (extract (day of d2), 30)-LESS (excerpt (d1 day), 30)
+ CASE when extracted (d2 day)< extract(day="" from="" d1)="" then="" 30="" else="" 0="" end ="">
d
D1 D2 DAYSBETWEEN
----------- ----------- -----------
October 10, 2013 5 December 2013 56
March 1, 2013 30 March 31, 2013
5 February 2013 March 31, 2013 56
February 25, 2013 March 23, 2013 29
February 25, 2013 March 31, 2013 36
August 2, 2013 29 October 2013 88
February 1, 2013 may 31, 2013 120
August 25, 2013 03 - Sep-2013 9
July 30, 2013 31 August 31, 2013
July 31, 2013 August 30, 2013 31
July 31, 2013 3 August 2013 4
July 3, 2013 August 31, 2013 58
31 August 2013 5 October 2013 36
5 February 2013 March 31, 2013 56
5 February 2013 March 5, 2013 31
February 5, 2013 February 5, 2013 1
In my view, which corresponds to your rules.
-
How to get the second Monday of each month in a given date range?
In Oracle forms, how to get the second Monday of each month in a given date range?
I tried below using the query WITH the Clause, but it seems that WITH Clause does not work in Oracle forms. So is there another way to do this in Oracle forms?
WITH month_range AS
(
SELECT TO_DATE ('Dec 2013', 'Mon YYYY') AS first_month
, TO_DATE ('Mar 2014', 'Mon YYYY') AS last_month
OF the double
)
SELECT NEXT_DAY (6 + ADD_MONTHS (first_month
, LEVEL - 1
)
, 'MONDAY '.
) AS second_monday
OF month_range
CONNECTION OF LEVEL < = 1 + MONTHS_BETWEEN (last_month, first_month)
;
Thanks in advance.
Good fishing, when the first day of the month is Thursday... So I changed the query accordingly... Try the below
SELECT CASE WHEN TO_CHAR (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'DY') = 'game '.
THEN NEXT_DAY (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'THU')
Of OTHER NEXT_DAY (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'Game') + 7
END AS second_day
FROM (SELECT SYSDATE startdate,
SYSDATE + 300 enddate
THE DOUBLE)
CONNECT BY LEVEL<=>=>
-
Find the time to restore a data file
RDBMS version: 11.2.0.4
Platform: Oracle Linux 6.4
To test our backup RMAN Tape (Netbackup), we have created a table called BACKUPTEST with a single space data file.
Then, we have removed the data file. Then was restored and recovered with RMAN's data file and tablespace was again online.
I wanted to show the evidence to my manager that the data file has been restored. But v$ datafile. CREATION_TIME will show the time when the tablespace is imagined. Is there another way, I could find the time when the data file has been restored other than log RMAN.
Below is an excerpt after the data file has been restored.
$ sqlplus / as sysdba
SQL * more: Production of the version 11.2.0.4.0 Fri dec 19 15:08:03 2013
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production
With partitioning, Real Application Clusters, Automatic Storage Management, OLAP,.
Options of Data Mining and Real Application Testing
SQL > select TABLESPACE_NAME, status of dba_tablespaces where nom_tablespace = 'BACKUPTEST ';
STATUS TABLESPACE_NAME
------------------------------ ---------
BACKUPTEST ONLINE
SQL > alter session set nls_date_format = "DD-MM-YYYY HH24."
Modified session.
SQL > select CREATION_TIME of v$ datafile where FILE # = 78;
CREATION_TIME
----------------
19/12/2013-12:16
SQL > select CREATION_TIME, last_time v$ datafile where FILE # = 78;
CREATION_TIME LAST_TIME
---------------- ----------------
19/12/2013-12:16
SQL >
19/12/2013 12:16 is the hour when the tablespace has been created with this data file no time, it has been restored from a backup RMAN.
Check the alert.log. There will be messages about the RESTORATION and RECOVERY actions.
Hemant K Collette
-
Find the name of ref vm data center
Hello
When I get VmCreatedEvent I get new vm REF. During the recovery of new VMs property, I would find the 'name of the Datacenter". I'm not able to cross over from the VM to the data center. Can someone help me with this?
I'm more trying traversal (vSphere SDK for Java):
PropertySpec dcSpec = new PropertySpec();
dcSpec.setType ("data center");
dcSpec.setPathSet (new String() {"name"});
hostPropSpec.setAll (false);
SelectionSpec recurseParents = new SelectionSpec();recurseParents.setName ("parent2parent");TraversalSpec dcTraversalSpec = new TraversalSpec();dcTraversalSpec.setType ("VirtualMachine");dcTraversalSpec.setPath ("parent");dcTraversalSpec.setName (recurseParents.getName ());dcTraversalSpec.setSelectSet (new SelectionSpec [] {recurseParents});PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.setPropSet (new [] {dcSpec} PropertySpec);
pfSpec.setObjectSet (new [] {oSpec} ObjectSpec);
return getService () .retrieveProperties (getContent () .getPropertyCollector (new PropertyFilterSpec [] {pfSpec}));
It does not work.
Thanks in advance.
Hello
I have the c# code for obtaining the name of ref. vm datacenter Here, I have explained how I got data center using vm ref in c#. I think it may useful allows you to get an equivalent in java.
steps to follow:
(1) download ref vm using the findbyip method by sending name datacenter as null.
ManagedObjectReference VMObject is _service. FindByIp (_sic.searchIndex, null, clientIp, true);
(2) get the vmparent as moref using getdynamicprop
ManagedObjectReference vmParent is GetDynamicProp (ManagedObjectReference) (VMObject, 'parent');.
(3) get the name of Datacenter as moref using getdynamicprop
Data Center ManagedObjectReference = (ManagedObjectReference) GetDynamicProp (vmParent, 'parent');
Let me know if you need an explanation of function getdynamicprop. I think it will be vijava CBC.
Thank you
Vijaya
-
get the month and year of date type
Hi all
I need to get the month and year of type date.
For example
Required result:select to_date('2011-01-17', 'yyyy-mm-dd') from dual;
Any ideas?01-2011
Thanks in advance,
Bahchevanov.select to_char(to_date('2011-01-17', 'yyyy-mm-dd'),'mm-yyyy') from dual;
HTH
-
Find the property of device a data store
In the VI client when you view storage information, you see the Identification of the store of data and in the peripheral next column.
This property of the unit is not available when you use Get-data store, is there a way to dig a little deeper and find? I need to list all my data warehouses and the information contained in this column of the device.
Thank you
Have a look at the script I gave in Get-datastore and ID LUN information.
If you only want the name of DS and the device, you can use the below condensed version.
function Get-DSDevice($dsImpl) { $ds = Get-View -Id $dsImpl.Id $esx = Get-View $ds.Host[0].Key $hss = Get-View $esx.ConfigManager.StorageSystem foreach($mount in $hss.FileSystemVolumeInfo.MountInfo){ if($mount.volume.name -eq $ds.Info.Name){ switch($mount.Volume.Type){ "VMFS" { foreach($ext in $mount.Volume.Extent){ if($mount.volume.name -eq $ds.Info.Name){ $device =$ext.DiskName + ":" + $ext.Partition } } } "NFS" { $device = $mount.Volume.RemoteHost + ":" + $mount.Volume.RemotePath } } } } $device } $report = @() Get-Datastore | %{ $row = "" | Select dsName, dsDevice $row.dsName = $_.Name $row.dsDevice = Get-DSDevice $_ $report += $row } $report
-
Cannot find the file error when loading data from text file to Oracle
Hello
I have an interface where I am loading a data from the text file to Oracle.
But when I try to do that I am getting following error.
ODI-1227: SrcSet0 (load) task fails on the source FILES SAPMM connections.
Caused by: java.sql.SQLException: file not found: d:/mdb/#General.get_filename
to com.sunopsis.jdbc.driver.file.FileResultSet. < init > (FileResultSet.java:160)
at com.sunopsis.jdbc.driver.file.impl.commands.CommandSelect.execute(CommandSelect.java:57)
at com.sunopsis.jdbc.driver.file.CommandExecutor.executeCommand(CommandExecutor.java:33)
SAPMM is the name of the connection.
I use get_filename to get the name of the file and it is fetching a correct value as long as this variable is updated in the previous stage of this interface.
KM, used for loading is SQL file
What would be the cause of this error?
Thank you
MaheshAlso a single query would be ok if I'm moving only generated package (according to your scenario3) scenario and not UI? It running properly?
Yes... It runs successfully
-
analyzing the graph of a given data output
Hello
I have this graph
These data are represented graphically by excel from an output of a data logger file.
I am looking at 4 main channels.
Channel 2 or 7 (they are pretty much the same thing... Purple is behind rose)
temperature of channel 8 (dark blue line) 22 c
Channel 9 37 c body temp (read line)
extreme temperature of channel 10 (green line) 60 C
my recorder, I'll make it through this test, I don't know how many times, but I know with certainty that these 3 times are the only values I'm looking for.
22, 37 and 60.
Anyway is to calculate the time it takes to 22 c to 90% of 37 C.
How do I put this logic? I want to do it for every jump in the graph.
22-37, 37-60, 22-37, 37-60
I have to calculate the time it takes 60-22
can someone me guy in the right directly.
Thank you
Watch in treatment-> palette of measurement of the Signal waveform. The transitional measure should do what you want.
-
Consecutive date grouping and find the largest number of consecutive group
Hi all
I have given dates and I want to find the largest number of consecutive dates
WIN_DATE_DATA
2015-09-22
2015-09-23
2015-09-27
2015-09-28
2015-09-29
2015-09-30
2015-10-1
In this example, there are 2 group of consecutive dates
Group 1
2015-09-22
2015-09-23
Group 2
2015-09-27
2015-09-28
2015-09-29
2015-09-30
2015-10-1
The OUTPUT should 5 which is the largest grouping of consecutive number.
Thanks in advance for the help!
Please take a look at the Community document: 101 PL/SQL: grouping sequence ranges (method Tabibitosan)
will allow you to do.
-
Cannot find the shaper tool and the app shows it is updated
Cannot find tool shaper in Illustrator and the app says that it is up-to-date.
I talked with Adobe - it seems that there was a file that was
set value.
This prevented the update programs.
On my Mac, I followed the following steps:
Finder > go > go to folder
type: / library
Open app support
File open Adobe
Open the AAMUpdater folder
Open the folder 1.0
Find the Adobe Updater Admin Prefs.dat file
Drag it to your desktop and open the with TextEdit
Change of > 1< to="" a="">0
Save your file
Drag it into your 1.0 folder
Restart your computer
Launch of creative cloud
Your applications must register that they have updates available.
Deb Zoglmann
Graphic Design program
Nevada regional technical center
900 W Ashland
Nevada, MO 64772
417-448-2090 Ext. 226
-
The end of the month selection
Hi all
We have a table say xyz with two columns month_cd and end_date where month is a code for each month and the end of the month is an end date of the regular calendar months and months where the end of the month is a day of weekend so for these months End_date is entered by a user in this table by another application. and we will have this information for al months in privious and current of the year
for ex:
Month_cd end_date
201101 01/30/2011
201102 03/04/2011
201103 03/31/2011
201104 04/30/2011
201105 06/04/2011
Now I have pick months based on the end_date, I mean everytime I run a query to select month_cd it must show date of cd for the month up to the endof month (maybe not a calendar end date)
How can achieve us? Please help me.SQL and PL - SQL forum would be more appropriate for this type of question, and you should always mention the full version of Oracle you are using (for example, 10.2.0.4).
Depending on the version of Oracle, there are several possible solutions. Here are a few that you can try:
--sample data: with t as ( select 201101 as month_cd, to_date('01/30/2011','mm/dd/yyyy') as end_date from dual union all select 201102 as month_cd, to_date('03/04/2011','mm/dd/yyyy') as end_date from dual union all select 201103 as month_cd, to_date('03/31/2011','mm/dd/yyyy') as end_date from dual union all select 201104 as month_cd, to_date('04/30/2011','mm/dd/yyyy') as end_date from dual union all select 201105 as month_cd, to_date('06/04/2011','mm/dd/yyyy') as end_date from dual ) --end of sample data select max(month_cd) keep (dense_rank first order by case when end_date >= trunc(sysdate) then end_date end nulls last) as month_cd from t;
--sample data: with t as ( select 201101 as month_cd, to_date('01/30/2011','mm/dd/yyyy') as end_date from dual union all select 201102 as month_cd, to_date('03/04/2011','mm/dd/yyyy') as end_date from dual union all select 201103 as month_cd, to_date('03/31/2011','mm/dd/yyyy') as end_date from dual union all select 201104 as month_cd, to_date('04/30/2011','mm/dd/yyyy') as end_date from dual union all select 201105 as month_cd, to_date('06/04/2011','mm/dd/yyyy') as end_date from dual ) --end of sample data select month_cd from ( select month_cd, end_date, (lag(end_date,1,to_date('01/01/1900','mm/dd/yyyy')) over(order by end_date))+1 as begin_date from t ) where trunc(sysdate) between begin_date and end_date ;
or
--sample data: with t as ( select 201101 as month_cd, to_date('01/30/2011','mm/dd/yyyy') as end_date from dual union all select 201102 as month_cd, to_date('03/04/2011','mm/dd/yyyy') as end_date from dual union all select 201103 as month_cd, to_date('03/31/2011','mm/dd/yyyy') as end_date from dual union all select 201104 as month_cd, to_date('04/30/2011','mm/dd/yyyy') as end_date from dual union all select 201105 as month_cd, to_date('06/04/2011','mm/dd/yyyy') as end_date from dual ) --end of sample data select month_cd from t where end_date=( select min(end_date) from t where end_date >= trunc(sysdate) ) ;
Kind regards
Bob -
OBIEE 11 g: how to find the 2nd Friday of the month
Hello
How to find the 2nd Friday of the month using the current date in obiee 11g.
Thanks in advance.
Kind regards
MIT.
Hey MIT,
You can try with something like this:
TIMESTAMPADD (SQL_TSI_DAY, TIMESTAMPADD (7 + 6-DAYOFWEEK (TIMESTAMPADD (SQL_TSI_DAY, 1-DAYOFMONTH (CURRENT_DATE), CURRENT_DATE))), (SQL_TSI_DAY, 1-DAYOFMONTH (CURRENT_DATE), CURRENT_DATE))
It can still be improved to probably avoid transformations 1-2, but at least he does.
You will need to check what return DAYOFWEEK in your environment for Friday (in mine Friday = 6) as if she does not return to Friday 6, you will need to adjust the formula.
The idea is to find what day is the first day of the month, since then visit the first Friday (or just stay there if the first day is a Friday). This is done by the DAYOFWEEK 6 (first day of the month).
And now, you just add more 7 days, so that's why there is a 7 + 6 - DAYOFWEEK (first day of the month) to make it easier to read and understand (instead of 13-...).
Maybe you are looking for
-
Sensor reading USB in the RT PC target.
Hello I have a sensor of incilinometer with USB port. After I installed the driver in windows, LabVIEW, he acknowledges with COM port and I can communicate with him through LaVIEW VISA. Now, I want to use this sensor on a target RT PC, but I encounte
-
I still need help: 11-24-10' uncorrected problem after all I have a laptop of refurbished HP older Pavilion ze5385US who has recently lost the wireless connection. Now, I have to leave it plugged in to use, not practical at all. I did the right cli
-
Ripple cannot packge Blackberry Webwork project
Hi all I'm new to Blackberry Webwork and I am trying to build the first ever webwork application for smart phone: the HelloWorld I installed Blackberry Webworks SDK for Smartphone in Win 7 2.3.1.5; with JDK 6 u33 My project located at C:\WWProjects\H
-
BlackBerry Smartphones Ringtones and alerts play regardless of the melody or volume control
KB24307-ringtones and alerts play regardless of the melody or volume control You can downgrade the operating system to an earlier version. Please backup your device before you begin. http://www.BlackBerryFAQ.com/index.php/How_do_I_downgrade_the_OS_on
-
Cannot save the ACS 5.4 as secondary for replication
Dear all, I am not able to regisrter my ACS in DR 5.4 as secondary to my primary ACS in DC 5.4 for replication. Attached is the error I get Kind regards Ranjit