is there an easy way to get the number of months in a year in a date range?
Hi, experts, I am a newbie.are there any easy ways to get the number of months in a year in a date range?
I would like to write a user-defined function.
the input parameters are startdate, enddate, year
the output is a number, not a month.
for example, case 1
StartDate = 01032009 (DDMMYYYY)
end date = 28022010 (DDMMYYYY)
If the year 2009, the output is 10
If the year = 2010, the output is 2
case 2:
StartDate = 10032009 (DDMMYYYY)
end date = 15032010 (DDMMYYYY)
If the year 2009, the output is 10
If the year = 2010, the output is 3
Thank you very much!
Hello
You can (also) try this:
SQL> with s as (
2 ------------ Sample data -------------
3 select to_date('01032009','ddmmyyyy') startdt, to_date('28022010','ddmmyyyy') enddt, 2009 yr from dual
4 union all
5 select to_date('01032009','ddmmyyyy') startdt, to_date('28022010','ddmmyyyy') enddt, 2010 yr from dual
6 union all
7 select to_date('10032009','ddmmyyyy') startdt, to_date('15032010','ddmmyyyy') enddt, 2009 yr from dual
8 union all
9 select to_date('10032009','ddmmyyyy') startdt, to_date('15032010','ddmmyyyy') enddt, 2010 yr from dual
10 ------------ Sample data -------------
11 )
12 select startdt, enddt, yr,
13 months_between(
14 least(trunc(to_date(yr+1,'yyyy'),'year') , add_months(trunc(enddt,'month'),1))
15 , greatest(trunc(to_date(yr,'yyyy'),'year') , trunc(startdt,'month'))
16 ) nbmonths
17 from s;
STARTDT ENDDT YR NBMONTHS
---------- ---------- ---------- ----------
01/03/2009 28/02/2010 2009 10
01/03/2009 28/02/2010 2010 2
10/03/2009 15/03/2010 2009 10
10/03/2009 15/03/2010 2010 3
It's pretty simple. (no connection with, without functions SQL only integrated multicast, etc...)
Tags: Database
Similar Questions
-
Get the number of month, week and day between 2 dates
Hi all
Is it possible to display the number of months, weeks and days between 2 dates? by using only the SQL or PL/SQL...
Entry:
Date: October 1, 2010
Date: October 19, 2010
I want output like below (assuming starts the week from Monday to Sunday in oracle).
October 1, 2010-(since it's in the middle of the week)
October 2, 2010-(since it's in the middle of the week)
October 3, 2010-(since it's in the middle of the week)
40. (4 Oct-10 Oct falls into the 40th week of the year)
41. (11 Oct-17 Oct falls into the 41st week of the year)
October 18, 2010-(since it's in the middle of the week)
October 19, 2010-(since it's in the middle of the week)
Note: If there is a month between the date, the number of the month should be displayed.
End of the month, the remaining date included with a full week, then the week of the year number should
displayed. After posting the week, remaining dates should be displayed as it is...
Appreciate your help...
Thank you.
Fox.You mean something like this...
SQL> ed Wrote file afiedt.buf 1 WITH t AS (select date '2010-09-27' as fdate, date '2010-11-21' as tdate from dual) 2 -- 3 -- END OF TEST DATA 4 -- 5 select dt2 6 from ( 7 select dt, 8 case when days_of_mn = days_in_month then 'Whole: '||to_char(dt,'Month') 9 when days_of_wk = 7 then 'Week: '||to_char(dt,'fmWW') 10 else to_char(dt, 'DD-fmMonth-YYYY') 11 end as dt2 12 ,row_number() over (partition by 13 case when days_of_mn = days_in_month then to_char(dt,'Month') 14 when days_of_wk = 7 then 'Week: '||to_char(dt,'fmWW') 15 else to_char(dt, 'DD-fmMonth-YYYY') 16 end order by dt) as rn 17 from ( 18 select dt, wk, mn, days_in_month 19 ,count(*) over (partition by wk) as days_of_wk 20 ,count(*) over (partition by mn) as days_of_mn 21 from ( 22 select fdate+rownum-1 as dt 23 ,to_number(to_char(fdate+rownum-1,'fmWW')) as wk 24 ,to_number(to_char(fdate+rownum-1,'fmMM')) as mn 25 ,to_number(to_char(last_day(fdate+rownum-1),'fmDD')) as days_in_month 26 from t 27 connect by rownum <= tdate-fdate+1 28 ) 29 ) 30 ) x 31 where rn = 1 32* order by dt SQL> / DT2 ----------------- 27-September-2010 28-September-2010 29-September-2010 30-September-2010 Whole: October Week: 44 Week: 45 Week: 46 19-November-2010 20-November-2010 21-November-2010 11 rows selected. SQL>
-
Is there an easy way to get the previous record in the Apex?
I'm new to APEX/Oracle, but have a lot of expierence as a mainframe programmer and some experience with SQL.
I have been instructed by my boss to create a set of pages in an application like this.
Page 1: Select an employee name and go to Page 2.
Page 2: View employee biography information.
Add a 'Next employee' button and a button "Previous employee" who picks the previous employees respectively biography info.
Essentially, he wants a query with information biography of each employee with an employee selected on page 1, used as pointer to start.
I built successfully "select the name of an employee on page 1" and "show its info on page 2" with a query that returns a single record.
What I can not know is how to get a next and previous button for the next or previous record in a record multi query, using the initially selected employee as intial pointer.
Is their an easy way to build this using functionailty of integrated APEX, or will it require programming to reach this requirement?Just realized that I didn't fully answer your question. According to the number of employees, you can create a collection to contain all the information and who travels with buttons. Or you could include a calculation to transmit the current employee, previous and next to your second page using the standard apex_application.gf01... GFN see the creation process to get the id of current line
Keep smiling,
Bob R -
Y at - it an easy way to get the sql code that is sent in the query UPDATE
I have a request to UPDATE abbreviated for readability. Is there an easy way to get the sql code that is sent? I use get this info for sql select in the display of debugging in cfeclipse but not for the UPDATE.
< cfquery debug = "" name = "q" datasource = "#datasource #" > "
UPDATE [BookingSystem]. [dbo]. [tbTrades]
SET
[Status] = #MATCHED_STATUS #.
WHEREclientID = < cfqueryparam value = "" #arguments.clientID # "cfsqltype ="cf_sql_integer"> AND"
< / cfquery >It might pay to read the docs for
- http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_p-q_17.html#1102316 - focusing on the RESULT parameter. Read also about debugging in CF: http://livedocs.adobe.com/coldfusion/8/htmldocs/Debug_01.html
--
Adam
-
easy way to get the size of a filling?
I have a program that uses a movieClip and draw a shape on it with beginFill, moveTo, lineTo, of of curveTo and endFill. Then, the user can resize and reform this form by dragging and pulling it off.
Is there an easy way to get the surface of the shape as the number of pixels that have been filled? Or I have to calculate what it based on points.
TIAWelcome to the forums. Here's a thread fairly new all about this topic.
Check that out and post if you have any questions.
-
At home, my wife and I have two computers four desktop computers and laptops. I often bring the laptop I got from my employer to use when I travel or work at home. Is there an easy way to identify the type of optical drive required by the optical drive in a computer? How to identify DVD + compared to a DVD player? I have never the disk right when I need to burn something. Thank you.
http://Windows.Microsoft.com/en-us/Windows-Vista/which-CD-or-DVD-format-should-I-use
Should which CD or DVD format I use
The above should help you.
http://Windows.Microsoft.com/en-us/Windows-Vista/burn-a-CD-or-DVD
General information on CD burning.
See you soon.
Mick Murphy - Microsoft partner
-
Is there an easy way to create "the mouse on the text, to display the image" without coding it? I want an image to appear only when you move to a line of text. I found the code for it but I want to find an easier way. I'm creating a home page with a list of text links. I want to design as well as in the overview of one of the text links, a corresponding image is displayed to the right of the page. I also need a default image to rest all the time unless one of the other links text is hovered over. Thank you!
Try to use a Widget for Composition in the Adobe Muse Widgets Panel.
I would like to start with a blank publication.
Place your text in the button area.
Place your image in the display area.
-
Is there an easy way to create the breadcrumbs in Muse?
I create a new site and I would like to add a few links of breadcrumb navigation, in addition to using the widget menu bar.
Is there an easy way to build the navigation bar links? Or I just create it manually?
No, right now it is not a widget that creates links from the navigation bar.
For now, you will need to manually create text links on each page to create the navigation bar navigation.
-
Is there a way to get the number of the current item?
In an article with multiple instances: is there a way to get the number of the current item? If for example, I'm on the 3rd point, is it some sort of integrated "GET CURRENT NUMBER REGISTRATION" which would return a '3' to the program?
Thank you
Published by: WayneFMcKinstry on April 9, 2010 10:50If I get you correctly in tabular element that you want to know the current record or current, you can try this...
For the current record
:SYSTEM.CURSOR_RECORD; or :SYSTEM.CURRENT_RECORD;
for the current element
:SYSTEM.CURSOR_ITEM;
-Clément
-
As the title says I made the mistake of putting different graphics on my website from different areas on my hard drive, is there an easy way to put them all in the same directory? Or I have to do it manually?
Always keep all files in the same folder, very important.
You can move them to the same folder, then right-click and select "link again assets" then find it.
Muse is quite good on discovery than other assets after that, it should automatically find all other assets in the folder you move them too.
otherwise you will have to connect manually, one by one
-
IIOMetadataNode is there an easy way to get all the items?
Y at - it an easy way to get all elements with no recursion to a depth of level in the XML getAsTree IIOMetadataNode ("formatname") document and make the images of type jpeg with EXIF metadata (when its present on the image) who return to the IIOMetadataNode?You can call getChildNodes() on the node returned by getAsTree(). The returned NodeList will contain children with a depth of level.
The EXIF data will be be summarised into a byte array [] under a sequence of 'unknown' marker with a value of 225 marker.
/**Returns the EXIF information from the given metadata if present. The * metadata is assumed to be in
javax_imageio_jpeg_image_1.0
* format. If the EXIF information were not present, then null is recuperer.* / public static ubyte [] getEXIF (IIOMetadata meta) {//javax_imageio_jpeg_image_1.0 //-->markerSequence //--->unknown (attribute: 'MarkerTag' val: 225 (for exif)) root IIOMetadataNode = (IIOMetadataNode) meta.getAsTree ('javax_imageio_jpeg_image_1.0');} IIOMetadataNode markerSeq = root.getElementsByTagName("markerSequence").item (0) (IIOMetadataNode); Notorious NodeList = markerSeq.getElementsByTagName ("unknown"); for (int i = 0; i)< unkowns.getlength();="" i++)="" {="" iiometadatanode="" marker="(IIOMetadataNode)" unkowns.item(i);="" if("225".equals(marker.getattribute("markertag")))="" {="" return="" (byte[])="" marker.getuserobject();="" }="" }="" return="" null;="">You must use a TIFFImageReader to analyze the table of byte [] being the TIFF metadata EXIF metadata.
-
Is there an easy way to convert the 3 tables in 1?
LabVIEW HelloWorld:
Is there an easy way to convert 3 one-dimentional tables in a table to two dimensions?
as shown below?
I tried the remodel, table vi, but could not get.
Thank you very much for your help.
\\carlos
For the example shown, this seems to work.
-
Is there an easy way to find the area of a shape?
I paint a picture of the spyder using partitions in an XML file. I use drawing methods to connect a bunch of points along certain rays. Once the shape is drawn, I would like to find the area. I could use trig and get the size of each triangular wedge of the shape, but I would steer clear of that if possible. Is there an easier way to do this?
Thanks in advancebecause for the loops and hitTest() run if soon there is no reason to use a monte carlo method to compute the area of a stage object. Indeed, using Math.Random () and 1/4 of the for loops is probably longer than the calculation of the area exactly:
-
Is there an easy way to reconnect the iPad Pro to my iPhone 6s longer hot spot?
Whenever the iPad Pro 'locks', connecting to my iPhone 6s hottest spot goes down, I can understand. No need to have the connection when not to use the iPad Pro. The problem is that you have to go all the way back in the reconnection of the hotspot settings. Is there an easier way? I wish it would just automatically reconnect.
Thank you
My 2 Air iPad automatically connects when I unlock it to the lock screen. You ask to join networks disabled in the WiFi settings?
-
Is there an easy way to get a Date/time string seconds?
I have 2 strings of the format depending on whether I would like to convert in seconds (since 1900). I need this value to set the t0 in a field.
Date: ' 30/06/2014 '.
"Time: '16:06 ' 08."
Is there a CVI function that will do this conversion for me? If not, is there an easy way to do it?
Thank you!
This code should do what you want:
static time_t calt;
struct Shared tm tm;
public static char msg [64];
public static int AA, mm, DD, hh, mn ss;strcpy (msg, ' 2014/06/30 16:06:08 ');
Extract the date/time string component
Scan (msg, "%d [x] %d [x] %d [x] %d [x] [x] %d %d", & mm, dd, and yy, & hh, & mn, &ss);)Transfer to a struct tm components
TM.tm_hour = hh;
TM.tm_min = mn;
TM.tm_sec = ss;
TM.tm_year = yy - 1900;
TM.tm_mon = mm - 1;
TM.tm_mday = dd;Obrtain calendar
CALT = 0;
CALT = mktime (&tm);)
Maybe you are looking for
-
Tecra S10 - 10F - need Server 2003 or 2008 LAN driver
I'm looking for a driver lan for Toshiba S10 - 10F for Windows Server 2003 or 2008.Or at least, I would like to know the model of network card. Thank you
-
P7-1235: helps p7-1235 video card!
Please someone help! I have a p7-1235 and I'm trying to upgrade to a video card to improve game performance. The problem I have is that I can't get a card to work. First of all, I tried XFX r9 270 x without a bit of luck, will not appear. Traded the
-
My Windows XP Movie Maker does not work on my laptop GOLD.
I can open it, but every time I try to download nothing happens. The files are in a flash drive and I can visualize, but when you try to download, it does not show that the document exists. I can download YouTube editor but is not a good editor. I do
-
Windows xp provided by blocking Yahoo constantly after telling me he wants to download flash player
IE hangs when that occurs the message flash player and then I have to go to Task Manager and end it and then restart IE. I can not download the flash player. even when I disable my Norton antivirus. I had flash player on my computer when this probl
-
WMP shows is not the files on my rocket I just synced
ARGH! I'm at my wit's end! I just synced my files on my card of 4 GB with WMP 11, in the car, select mode (I know, I know that everyone says not to do, but it worked until last night!). When I went to check on the unit this morning, it says no file