How to get the number of days of a month belonging to a date interval
Hi, i am getting mad around a problem, i have 2 dates and a month, i wanto to retrieve the number of days belonging to the month that are in the interval.
eg:
month january 2011 . begin_date = 11/JAN/2011, END_DATE 30/MAY/2011 result is 21
month january 2011 . begin_date = 11/DEC/2010, END_DATE 10/JAN/2011 result 10
month january 2011 .begin_date = 02/FEB/2011 , END_DATE 25/may/2011 result 0
month january 2011. begin_date = 03/JAN/2011 , END DATE 05/JAN/2011 result 3
and so on ...
i appreciate any suggestion
thank you
Andrea
Oh, I didnt see your result.
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 union all
6 select to_date('11/12/10','dd/mm/yy') from_dt,
7 to_date('10/01/11','dd/mm/yy') to_dt,
8 'Jan-11' mnth from dual
9 union all
10 select to_date('02/02/11','dd/mm/yy') from_dt,
11 to_date('25/05/11','dd/mm/yy') to_dt,
12 'Jan-11' mnth from dual
13 union all
14 select to_date('03/01/11','dd/mm/yy') from_dt,
15 to_date('05/01/11','dd/mm/yy') to_dt,
16 'Jan-11' mnth from dual
17 )
18 select from_dt,to_dt,mnth,
19 greatest(
20 least(last_day(to_date(mnth,'Mon-yy')),to_dt)
21 -
22 greatest(to_date(mnth,'Mon-yy'),from_dt)+1
23 ,0) cnt
24 from t;
FROM_DT TO_DT MNTH CNT
11-JAN-11 30-MAY-11 Jan-11 21
11-DEC-10 10-JAN-11 Jan-11 10
02-FEB-11 25-MAY-11 Jan-11 0
03-JAN-11 05-JAN-11 Jan-11 3
Similar Messages
-
How to get the number of days in a month?
hi all
is there any way to get the number of days in a given month with a given year? for instance, if year is 2004 and the month is July or February, how can i get the number of days? thanks.Gee, I don't know ... Maybe this:
Calendar cal = Calendar.newInstance();
cal.set(Calendar.YEAR, 2004);
cal.set(Calendar.MONTH, Calendar.FEBUARY);
System.out.println("max days in month: " + cal.getActualMaximum(Calendar.DAY_OF_MONTH));
Do you not bother reading what people have already posted? Read the API docs on the Calendar class. -
How to get the number of days of February.....
Hi ,
how can I get the number of days (28 or 29) of February of the current year or the next...????
Or is there any other way to find that a year is a leap or not (i mean the year has 365 or 366 days).??
Thanks
Simonselect add_months(to_date('&v_year', 'YYYY'), 12) -
to_date('&v_year', 'YYYY') from dual;Jens, it seems we have made the same mistake, trunc usage seems mandatory :
SQL> ed
Wrote file afiedt.buf
1* select add_months(to_date('2007', 'YYYY'), 12) - to_date('2007', 'YYYY') from dual
SQL> /
ADD_MONTHS(TO_DATE('2007','YYYY'),12)-TO_DATE('2007','YYYY')
366
SQL> ed
Wrote file afiedt.buf
1* select add_months(trunc(to_date('2007', 'YYYY'), 'YYYY'), 12) - trunc(to_date('2007', 'YYYY'), 'YYYY') from dual
SQL> /
ADD_MONTHS(TRUNC(TO_DATE('2007','YYYY'),'YYYY'),12)-TRUNC(TO_DATE('2007','YYYY')
365
SQL> Just to clarify my past doubt.
Nicolas. -
How to get the number of days between 2 given dates
Hi all,
How can I find the number of days between any 2 given dates.
ThanksHi
Here's a dirty way:
If you've got two Date objects in Java, call getTime() on each one (which gives you a value in milliseconds), then subtract the two millisecond values, and divide the result by the number of milliseconds in a day (24 * 60 * 60 * 1000). There's more `elegant' ways to do this, but this method only requires one line of Java.
Best wishes
Kevin -
FM to get the number of days in Year,month and days by giving number of day
Hi ALL,
This is quit differnt.
I need to give input the 'start date' and the 'number of days' and get the total days from the start date in year,month and day format.
for example.
start date :01.01.2009
number of days as 32
then i should get
years:0
months :1
days :1
Pleas help me out.hi Anusha,
first u pass the date and the days to the following fm you will get the result date....
data:date type sy-datum,
r_date(10) type c.
date = sy-datum.
CALL FUNCTION 'CALCULATE_DATE'
EXPORTING
DAYS = '32'
MONTHS = '0'
START_DATE = date
IMPORTING
RESULT_DATE = r_date
write:/ r_date.
then you need to pass the result date and the date to the following fm to get the required output...
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
date1 = r_date
date2 = date
IMPORTING
years = v_years
months = v_months
days = v_days
EXCEPTIONS
invalid_dates_specified = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
here u will get the difference in days, months and year...
i hope u wil get help from this...
regards
Ashu Singh -
hai bloggers,
see we have 365 days per year for first half we are going to have 180+ days (if we select first half as the prompt and we select week number as prompt and the last date of that particular week should show in the report)and number of days upto that date or week also should display...if we select second half and week number of that particular half it should show number of days upto that week and highest date of that week number of days should count from 1 to 180+ only mean (july 1 st is 1 st day)
thanksYou need to use timestampdiff function for calculating number of days. One of the way to calculate is like this
case when "Time"."Calendar Half Year" = 1 then timestampdiff(SQL_TSI_DAY,CAST(EVALUATE('TO_DATE(%1,%2)','01-01'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE),CAST(EVALUATE('TO_DATE(%1,%2)','30-06'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE)) else timestampdiff(SQL_TSI_DAY,CAST(EVALUATE('TO_DATE(%1,%2)','01-07'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE),CAST(EVALUATE('TO_DATE(%1,%2)','31-12'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE)) end
If you want calculate between 1st day of the half and last date of a week then use following
case when "Time"."Calendar Half Year" = 1 then timestampdiff(SQL_TSI_DAY,CAST(EVALUATE('TO_DATE(%1,%2)','01-01'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE),MAX(MAX("Time"."Calendar Date"))) else timestampdiff(SQL_TSI_DAY,CAST(EVALUATE('TO_DATE(%1,%2)','01-07'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE),MAX(MAX("Time"."Calendar Date"))) end
Hope it will answer your question
Thanks,
Phani. -
How to get total number of days
Hi All,
how to get total number of days , for example if month eq 05 then need to get total number of days until MAY 31.
and how to get total number of days in a month.
Thank You,,
Sriii..Hi Sridhar,
Pls Try to search before posting general questions.
Try this,
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = p_lv_date1
i_datum_von = p_lv_date2
IMPORTING
e_tage = p_e_date_difference
EXCEPTIONS
days_method_not_defined = 1
OTHERS = 2
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Regards,
Sunil kairam. -
Indesign CS3: How to get the number of the current layer?
Hallo!
How to get the number of the current layer in a page?
Thanks,
Alois BlaimerInterfacePtr<ILayerList> layerList(documentUIDRef, UseDefaultIID()); <br /><br />int32 layerCount = layerList->GetCount();<br /><br />To findout layer name use<br /><br />IDocumentLayer* documentLayer = layerList->QueryLayer(layerIndex);<br /> <br />PMString layer=documentLayer->GetName();
-
How to get the number of columns in a result set???
hi everyone..
i am trying to establish a servlet applet communication....
my applet send the sql query to the servlet as serialised string and then the servlet executes the query...
Since i need to pass the result back to the applet, i thaught of passing the whole reult set to the applet..but that seems to be not possible..
so i thaught of storing my result set data in a vector and then pass the vector,but the first problem that i came across is that how to get the number of colums in a result set....
so is there a way to get the number of columns in a result set...???
and also i would like to know if it possible to send my whole result set to the applet bye serialization or by any method...???
thanx in advanceYou shouldn't do. It expenses resources (you should always close the ResultSet and the Statement as fast as possible). Simply gently process it into a Collection or Map of DTO's. Those are serializable.
-
How to get the number of files currently open?
hi,
does any one know how to get the number of files currently open in windows OS?
e.g. lets say .txt files...
any comment will be really appreciated.
thanksAssuming that you don't want to actually do this from within Java code (which would obviously require native code), here's a utility that will give you a list of which file handles are opened by which processes (on Windows):
http://www.sysinternals.com/ntw2k/freeware/handle.shtml
- K -
How to get the number of elements in DB
Could you tell me how to get the number of elements in DB??
My code to get the number is below, but I think it is not efficient
DB->cursor(DB, NULL, &cursorp, 0);
while ((ret = cursorp->c_get(cursorp, &key, &data, DB_NEXT)) == 0)
count++;
--------------------------------------------------------------------------------------------------------------Hi,
The most efficient way to get a count from the database is using the DB->stat API (http://docs.oracle.com/cd/E17076_02/html/api_reference/C/dbstat.html)
The code will be something like:
DB *dbp;
DB_BTREE_STAT *statp;
int ret;
/* Print out the number of records in the database. */
if ((ret = dbp->stat(dbp, NULL, &statp, 0)) != 0) {
dbp->err(dbp, ret, "DB->stat");
goto err1;
printf("%s: database contains %lu records\n",
progname, (u_long)statp->bt_ndata);
free(statp);The code comes from the example included in the distribution at examples/c/ex_btrec.c
If the database isn't a btree, you should update to the appropriate statistics structure and field.
It's worth noting that retrieving the count is never a "cheap" operation. The count is not stored in the database - since doing so introduced a single point of contention that creates a bottle neck.
Regards,
Alex Gorrod
Oracle Berkeley DB -
How to get the number of messages consumed by a MDB ??
Hi all,
How to get the number of messages consumed by a MDB displayed in OEM in a Java Application ???
DMS ??? what use DMS ???
tanksok.
Well using DMS is one way to get at these sorts of stats in a programmatic manner.
There's a Java API you can use, or you could call out to the Spy servlet to query the DMS stats in either text or XML form.
I don't have an MDB published so I can't show you specifiically, but here's the sort of query you can use to extract the data.
http://localhost:8888/dms0/Spy?format=raw&table=oc4j_ejb_stateless_bean&recurse=children
Which produces a table of the TEXT form:
<DMSDUMP version='9.0.4' timestamp='1163456821185 (Tue Nov 14 08:57:01 CST 2006)' id='8888' name='OC4J'>
<statistics>
/oc4j [type=n/a]
/oc4j/default [type=oc4j_ear]
/oc4j/default/EJBs [type=oc4j_ejb]
/oc4j/default/EJBs/jmsrouter_ejb [type=oc4j_ejb_pkg]
/oc4j/default/EJBs/jmsrouter_ejb/AdminMgrBean [type=oc4j_ejb_stateless_bean]
pooled.count: 11 ops
pooled.maxValue: 1 count
pooled.minValue: 0 count
pooled.value: 0 count
ready.count: 11 ops
ready.maxValue: 1 count
ready.minValue: 0 count
ready.value: 0 count
session-type.value: Stateless
transaction-type.value: Bean
/oc4j/default/EJBs/jmsrouter_ejb/EnqueuerBean [type=oc4j_ejb_stateless_bean]
pooled.count: 11 ops
pooled.maxValue: 0 count
pooled.minValue: 0 count
pooled.value: 0 count
ready.count: 11 ops
ready.maxValue: 0 count
ready.minValue: 0 count
ready.value: 0 count
session-type.value: Stateless
transaction-type.value: Bean
/oc4j/default/EJBs/jmsrouter_ejb/TimerHandlerBean [type=oc4j_ejb_stateless_bean]
pooled.count: 11 ops
pooled.maxValue: 0 count
pooled.minValue: 0 count
pooled.value: 0 count
ready.count: 11 ops
ready.maxValue: 0 count
ready.minValue: 0 count
ready.value: 0 count
session-type.value: Stateless
transaction-type.value: Bean
</statistics>
</DMSDUMP>
Or produces an XML document of the form:
http://localhost:8888/dms0/Spy?format=xml&table=oc4j_ejb_stateless_bean&recurse=children
You can use the Spy console to find the table that contains the details for MDB and then take it from there.
This is not what you specifically want to do, but it does provide a good overview of how DMS is used.
http://www.oracle.com/technology/pub/notes/technote_dms.html
-steve- -
How to get the number of bytes at TCP port
Hi all,
How to get the number of bytes to read at the TCp port...as someone had suggested in some forum we do read the number of bytes first and then pass this...
but we get a problem when we have FF data in this...because then it sends 2 FF data...and cause of this we skip the last data...is there any solution for the same?Hi
In LabVIEW you don't have the same property as in serail port.
You havn't "Byte at TCPIP port".
if you developp a protocol, one soltion, is to send the size to read.
Ingénieur d'Application / Développeur LabVIEW Certifié (CLD)
Application Engineer / LabVIEW Certified Developer (CLD) -
How to get the number of decimal places configured for a site column
Hi,
I have a column 'SampleNumCol' of type Number, the number of decimal places to be displayed is configured as 2.
The column conatins a value, but when retrieved programatically is displayed as 5.00000000 instead of 5.00.
I am retrieving this column using listitem.Properties[field.InternalName].
I need to trim the decimals based on number of decimal places configured for the site column.
How to get the number of decimal places configured for a site column?
Thanks in advance,
dhijitGet the field as SPFieldNumber and then check DisplayFormat which returns
SPNumberFormatTypes
SPFieldNumber numberField = list.Fields.GetFieldByInternalName("YourNumberFieldName") as SPFieldNumber;
SPNumberFormatTypes numFormatType = numberField.DisplayFormat; -
How To get the number of request's for a single Composite Application
Hi can any body tell how to get the number requst's for a single composite application.
Thanks
ManiHi,
There are lots of STATE is available for composite instances, like mentioned in the below query. I hope you will get answer from the below query.
SELECT (CASE WHEN STATE=1 THEN 'OPEN AND RUNNING'
WHEN STATE=2 THEN 'OPEN AND SUSPENDED'
WHEN STATE=3 THEN 'OPEN AND FAULTED'
WHEN STATE=4 THEN 'CLOSED AND PENDING'
WHEN STATE=5 THEN 'CLOSED AND COMPLETED'
WHEN STATE=6 THEN 'CLOSED AND FAULTED'
WHEN STATE=7 THEN 'CLOSED AND CANCELLED'
WHEN STATE=8 THEN 'CLOSED AND ABORTED'
WHEN STATE=9 THEN 'CLOSED AND STALE'
WHEN STATE=10 THEN 'NON-RECOVERABLE'
ELSE STATE || ''
END) AS STATE, component_name, COUNT(*) AS NUM_OF_CUBE_INST FROM CUBE_INSTANCE where composite_name='PASS THE COMPOSITE NAME HERE..........'
group by (CASE WHEN STATE=1 THEN 'OPEN AND RUNNING'
WHEN STATE=2 THEN 'OPEN AND SUSPENDED'
WHEN STATE=3 THEN 'OPEN AND FAULTED'
WHEN STATE=4 THEN 'CLOSED AND PENDING'
WHEN STATE=5 THEN 'CLOSED AND COMPLETED'
WHEN STATE=6 THEN 'CLOSED AND FAULTED'
WHEN STATE=7 THEN 'CLOSED AND CANCELLED'
WHEN STATE=8 THEN 'CLOSED AND ABORTED'
WHEN STATE=9 THEN 'CLOSED AND STALE'
WHEN STATE=10 THEN 'NON-RECOVERABLE'
ELSE STATE || ''
END), component_name;
Thanks,
Vijay
Maybe you are looking for
-
How to trigger a java program on INSERT in SAP HANA
Hi, I need to trigger a java program whenever an INSERT happens on a table in SAP HANA. Please tell me how can I achieve the same. Thanks & Regards Divyank Mehta
-
Ever since i downloaded the new software my music on my phone is way our of order
i need to know how to fix my phone music library its all out of order
-
Why does Firefox crash when ever I want to print an email or something from the web?
If you choose print on the browser it will go to this dialog box where you click print and after clicking the browser will crash and another box will appear stating that it crash and wants to know if you would like to submit a report.
-
Hi, I need a tool to integrate open source library in my project. What I need is: I have a background image with fixed points designed that could, for example, represent the buildings, and I want to draw on this image of moving objects, as if they mo
-
Illustrator bugged out when going from 2 monitors to 1
I went from 2 monitors to 1 and now my illustrator is all messed up. For example, when i try to open a new document, this is the dialog I get. I tried resetting the workspace and preferences but no luck.... Tried holding alt ctrl shift when starting