Conversion of days to year&months (HR)
Hi friends,
I'm working for one BI HR report, where i'm getting employee experience in days. I want to convert days into years& months. Eg: 850 days means 2 yrs 4months. At cube level i'm getting number of days, how can i get it at query level?
thanks,
Sridhar
please find the complete code
DATA: L_DATE TYPE D,
L_TIME TYPE T,
E_TIMESTMP like RSGENERAL-TIMESTMP,
FINAL_DATE(16),
INDATE LIKE PSO02-ZFBDT,
DD TYPE i,
MM TYPE i,
yy TYPE i.
PARAMETERS: I_DAYS TYPE i.
GET TIME STAMP FIELD E_TIMESTMP.
CONVERT TIME STAMP E_TIMESTMP TIME ZONE 'UTC+12' INTO
DATE L_DATE TIME L_TIME.
SUBTRACT I_DAYS FROM L_DATE.
CONVERT DATE L_DATE TIME L_TIME INTO
TIME STAMP E_TIMESTMP TIME ZONE 'UTC+12'.
FINAL_DATE = E_TIMESTMP.
INDATE = FINAL_DATE+1(8).
CALL FUNCTION 'FI_PSO_FULL_DAY_MONTH_YEAR_GET'
EXPORTING
I_DATE_FROM = SY-DATUM
I_DATE_TO = INDATE
IMPORTING
E_DAYS = DD
E_MONTHS = MM
E_YEARS = YY .
WRITE:/ yy, mm, dd.
but FM 'FI_PSO_FULL_DAY_MONTH_YEAR_GET' is not avialble in BI side, it is there in R/3 . You need to create in BI, then you can use it.
bhaskar
Similar Messages
-
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 -
How to convert days to years, months and remaining days
Hi All,
I have the number of days for example : 398 days how to
convert 398 days to number of years and number of months and remaining days
like 398 days 1 year , 1 month and 2 days
Regards
rkraoe.g.
SQL> select sysdate, sysdate - 1234 from dual
2 /
SYSDATE SYSDATE-1
09-AUG-06 24-MAR-03
SQL> select trunc(trunc(months_between (sysdate, sysdate - 1234))/12) yrs,
2 mod(trunc(months_between(sysdate, sysdate - 1234)), 12) mnths,
3 sysdate - add_months((sysdate - 1234), trunc(months_between(sysdate, sysdate - 1234))) dys
4 from dual
5 /
YRS MNTHS DYS
3 4 16
SQL> -
Day/Month appearing as Day of Year/Month
When I look at dates displayed for Time Machine (right hand date bar) I notice they display as Wednesday, 132 May 2010 then Wednesday, 139 May 2010 etc. Is there a way to get back to the actual day/month/year format I specify for an Australian machine? I have noticed similar date displays within Software Update and iSync.
Thanks, the Region under Language and Text>Formats was listed as Custom. I changed it to Australia and this had rectified the problem when I Restarted and checked Time Machine.
Cheers Gavin -
Difference between two dates is required in years & months
Hi all,
<b>1.</b> I want difference of two dates in years & months. For e.g. date1 is 29.09.1998 & date2 is 02.05.2001. I want date2-date1 to be calculated & displayed as 2.7 (yrs)in BEx.
<b>2. </b> Also, while calculating overalll result it should calculate as :
E.g. 2.7+ 2.6 = 5.1 (yrs)
Right now I am getting difference in days. Is there any way to convert it in yrs & months.
Note:string 'yrs' is not required
Thanks in advance.
HimanshuHi,
Reply by Arun was immensely helpful.
To do calculation I used the following formula.
TRUNC ( 'DATE DIFFERENCE' / 365 ) + TRUNC ( FRAC ( 'DATE DIFFERENCE' / 365 ) * 12 ) / 100
where 'DATE DIFFERENCE' is difference of two dates in days (Employment start date - employment end date). By this I am getting number of days in years & months. -
Release Date for Albums Year, MONTH DAY
Why can't I enter the release date for albums (Year month and day)? Itunes has a field for year but that's it. I would have loved to be at the meeting where it was discussed.
"Year, month and day? why the heck would any want that?"
"Well a lot of us want to see our albums in chronological order and you can't do that with just the year, many albums come out every year"
"Blah Blah Blah, music is just to dance to, no one cares about dates, besides it would four extra digit fields in each entry"
But seriously, I would think that Itunes would aspire to be THE program for music lovers.
Instead of being able to just enter the release dates I have had to come up with my own work around. I put a the release date in the format yyyymmdd in fromt of each title and then sort by titles.
Now all of my Beatle albums finally show up in chronological order by release date. But why should I have to massage the data like this. I can't imagine what goes on at Itunes planning sessions. I'm very unhappy about the loss of cover flow but that's another story.I'm glad to hear that I am not the only one who sees this as a problem. And another Beatles fan too.
This is so fundamental. Every album has a release date and it's part of the data that is always associated with that album. Why did Apple look at the data available for an album and consciously decide to truncate it?
What kind of music lover isn't aware of when albums are released? I just don't get it.
I like having the date yyyymmdd in front of each album. It isn't pretty but it means the albums are chronological. If you want, you could just put this in the sort field and leave the regular album title in the regular field. Then the names would be right and they would sort correctly. But again. Why should we have to do all that?
Apple is busy constantly changing where the controls are on I tunes rather than fixing something simple and important like this.
Today I wanted to load some songs onto my ipod touch and it took me 10 minutes to figure out how to sync because the last itunes update got rid of the side bar.
How are you supposed to get comfortable using a product when they keep moving the controls around? Just quit apple. leave the controls where they are. Add new controls if needed but stop moving them. I know I'm ranting now but I am honestly angry and frustrated, -
How to get same day of a month in every year in the DB ( To update a flag )
Hi,
I am trying to formulate an update query for a flag table in our database which contains dates, and flag columns. Currently the system have dates for the next ten years. The flags are updated with values 0 or 1 if a particular date falls under the required criteria.
I need to update flag column for the same day of the month in every year. e.g. 2nd Sunday of October. The value should be updated to all years in the table. Currently I am using the following query to update the current year.
UPDATE FILTERCALENDAR SET YEAR_WINDOW=1 WHERE c_date = NEXT_DAY( TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1)*7;
and for next year Like
UPDATE FILTERCALENDAR SET YEAR_WINDOW=1 WHERE c_date = add_months(NEXT_DAY( TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1)*7,+12)-1;
This is not an excellent way to do it as it does not take care of leap years and it does not scan and update values in the whole table for all years correctly.
Can any one help me to resolve this please.Hi,
user10903866 wrote:
Hi,
I am trying to formulate an update query for a flag table in our database which contains dates, and flag columns. Currently the system have dates for the next ten years. The flags are updated with values 0 or 1 if a particular date falls under the required criteria.
I need to update flag column for the same day of the month in every year. e.g. 2nd Sunday of October. The value should be updated to all years in the table. Currently I am using the following query to update the current year.
UPDATE FILTERCALENDAR SET YEAR_WINDOW=1 WHERE c_date = NEXT_DAY( TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1)*7;That's the 2nd Sunday after October 1; the 2nd Sunday of October is the 2nd Sunday after September 30, so you need to subtract 1 more day before calling NEXT_DAY.
I'd do it this way:
WHERE c_date = NEXT_DAY ( TO_DATE ( '01-OCT-2013', 'DD-MON-YYYY') - 8
, 'SUNDAY'
) + (7 * 2) -- Last number is week numberRemember, calling NEXT_DAY like this depends on your NLS_DATE_LANGUAGE.
and for next year Like
UPDATE FILTERCALENDAR SET YEAR_WINDOW=1 WHERE c_date = add_months(NEXT_DAY( TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1)*7,+12)-1;If you want the 2nd Sunday in October, 2014, then take the previous expression, and just change 2013 to 2014:
WHERE c_date = NEXT_DAY ( TO_DATE ( '01-OCT-2014' -- or any month and year you want
, 'DD-MON-YYYY'
) - 8
, 'SUNDAY'
) + (7 * 2) -- Last number is week number
This is not an excellent way to do it as it does not take care of leap years and it does not scan and update values in the whole table for all years correctly.
Can any one help me to resolve this please.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
Explain, using specific examples, how you get those results from that data.
See the forum FAQ {message:id=9360002} -
How to get date difference in terms of years,months and also days
Tool : Eclipse
Framework : JSF & Springs
JRE : jdk1.5.0_06
Iam using oracle 10G DB as back end.I have two date fields in a table.
1)premium_paying_start_date
2)premium_paying_end_date
Iam getting these two dates from the database and storing these values within a entity.Now in the delegate layer,
i have to get the premium_term i.e, the difference between the two dates(premium_paying_end_date-premium_paying_start_date).
The difference should show the year,month and no of days difference.
For example :
premium_paying_start_date : 14-10-1984
premium_paying_end_date : 01-03-2008
Difference should be : 23 Y : 4 M : 15 D (Y = years, M = months , D= days)
So please give me the solution for this.Difference should be : 23 Y : 4 M : 15 D (Y = years, M = months , D= days)
So please give me the solution for this.How did you determine what the difference should be?
~ -
Elapse days - calculation from month and year
Duplicate thread ...
coding required for converting month into days
I have Month and year field in my DSO --Year( 2009), Month(4)
I want below logic to calculate -
MTD qty % = (qty * elapse days) / no of days in month
so from the above, I want to know,
1. How can we get the no of days from the above 2 objects (year and month).
2. Elapse days are the days that are over from current date to Ist day of that month.
eg: current date - 04.03.2009 , 1st day of the month - 04.01.2009,
elapse days = 2. (you need to consider all days in the month, not only working days)
so my questions is how can we get, # of days n a month from above 2 fields and elapse days based on the above condition.
also want to know, where can I have the logic in transformations or query level.
please provide your suggestions.
Thanks,
Pra
Edited by: Arun Varadarajan on Apr 5, 2009 10:44 PM
Edited by: Arun Varadarajan on Apr 5, 2009 10:45 PMHello,
I think the sample program below does what you ask: it finds the days in the month (bit of an overkill to use function modules for that) and then computes the QTD.
Note that the internal string representation of a data variable is always YYYYMMDD, regardless of the "externalized" form (e.g. yyyy/mm/dd or dd.mm.yyyy), so this code will work regardless of your custom date format.
Regards,
Mark
REPORT zqty_to_date.
PARAMETERS:
p_date TYPE dats,
p_qty TYPE i.
DATA:
days TYPE i,
n_year TYPE numc4,
n_month TYPE numc2,
n_day TYPE numc2,
qtd(6) TYPE p DECIMALS 1.
START-OF-SELECTION.
n_year = p_date+0(4).
n_month = p_date+4(2).
n_day = p_date+6(2).
PERFORM days_in_month USING n_year n_month CHANGING days.
qtd = ( p_qty * ( n_day - 1 ) ) / days.
WRITE: / 'Days in month:', days,
/ 'Qty to date :', qtd.
*& Form days_in_month
* text
FORM days_in_month USING year month CHANGING days.
DATA: ymod4 TYPE i,
ymod100 TYPE i,
ymod400 TYPE i.
CASE month.
WHEN 4 OR 6 OR 9 OR 11.
days = 30.
WHEN 2.
ymod4 = year MOD 4.
ymod100 = year MOD 100.
ymod400 = year MOD 400.
IF ( ymod4 = 0 AND ymod100 > 0 ) OR ( ymod100 = 0 AND ymod400 = 0 ).
days = 29.
ELSE.
days = 28.
ENDIF.
WHEN OTHERS.
days = 31.
ENDCASE.
ENDFORM. "days_in_month -
First day of current month, one year ago
All,
Does anyone have a calculation or know how I can calculate the first day of the current month, one year ago? I am trying to setup a filter criteria to show all records created >= 1st day of current month for prior year and <= the last day of the prior month. I have the second half of the equation for last day prior month but need some help on the first half.
Thanks in advance for any pointers!
DYou can try:
SELECT TRUNC(ADD_MONTHS(sysdate, -12), 'MON') FROM dual;
Or
SELECT TRUNC(sysdate-NUMTOYMINTERVAL(1,'YEAR'), 'MON') FROM dual; -
How to add a date(Year, Month, Day) table in OBIEE Administrator
Hi,
I am new to this tool, we are developing a HR report for emp on leave or absentees. we have data since 1982 in our tables. we want to have a date table and dimension where we can give have a hierarchy for year, month, day, so that we can design our dashboards based on time. how we can do that in OBIEE Administrator and can we do it in warehouse builder as well, if so, how. ( we have a column for date in the table by name 'leave start date' and 'leave end date', can we use this and create our own table with year month and day as separate columns).
Thanks.hi,
Using date column u can create time dim in BMM layer
Create a new logical table and pull your date column to this table
Next,create following columns
Refer http://www.rittmanmead.com/2007/04/30/obi-ee-time-dimensions-and-time-series-calculations
leave start date
Year level :Extract(year from date_column)
Month and year level:CAST (Extract(month from fact_date_column) As CHAR(5) ) || CAST (Extract(yearfrom fact_date_column) As CHAR(5) )
Mon-YYYY: EVALUATE('TO_CHAR(%1,%2)' AS CHARACTER ( 30 ), "Development".""."sample sales"."Dim - leave Date"."REPORT_DATE", 'MON-YY')
YYYY-MM : CAST ( EXTRACT( YEAR FROM "sample sales".""."sample"."Dim - Report Date"."LEAVE_DATE") AS CHARACTER ( 4 )) || '/' || CASE WHEN EXTRACT( MONTH FROM "sample sales".""."sample"."Dim - Report Date"."LEAVE_DATE") BETWEEN 10 AND 12 THEN CAST ( EXTRACT( MONTH FROM "sample sales".""."sample"."Dim - Report Date"."LEAVE_DATE") AS CHARACTER ( 2 )) ELSE '0' || CAST ( EXTRACT( MONTH FROM "sample sales".""."sample"."Dim - Report Date"."LEAVE_DATE") AS CHARACTER ( 1 )) END
Year Quater :: EVALUATE('TO_CHAR(%1,%2)' AS CHARACTER ( 6 ), "sample sales".""."sample"."Dim -Leave Date"."REPORT_DATE", 'YYYY') || '0' || EVALUATE('TO_CHAR(%1,%2)' AS CHARACTER ( 6 ), "sample sales".""."sample"."Dim -Leave Date"."REPORT_DATE", 'Q')
Day: EXTRACT(DAY FROM DATE_COLUMN)
Thanks,
Saichand.v -
How to get the difference of two dates in years,months and days
Hi friends,
how to get the difference of two dates in years,months and days
for ex 2 years 3 months 13 days
select (sysdate-date_Start) from per_periods_of_service
thanksSomething like this...
SQL> ed
Wrote file afiedt.buf
1 with t as (select to_date('17-nov-2006','dd-mon-yyyy') as c_start_date, to_date('21-jan-2008','dd-mon-yyyy') as c_end_date from dual union all
2 select to_date('21-nov-2006','dd-mon-yyyy'), to_date('17-feb-2008','dd-mon-yyyy') from dual union all
3 select to_date('21-jun-2006','dd-mon-yyyy'), to_date('17-jul-2008','dd-mon-yyyy') from dual
4 )
5 -- end of test data
6 select c_start_date, c_end_date
7 ,trunc(months_between(c_end_date, c_start_date) / 12) as yrs
8 ,trunc(mod(months_between(c_end_date, c_start_date), 12)) as mnths
9 ,trunc(c_end_date - add_months(c_start_date, trunc(months_between(c_end_date, c_start_date)))) as dys
10* from t
SQL> /
C_START_D C_END_DAT YRS MNTHS DYS
17-NOV-06 21-JAN-08 1 2 4
21-NOV-06 17-FEB-08 1 2 27
21-JUN-06 17-JUL-08 2 0 26
SQL>But, don't forget that different months have different numbers of days, and leap years can effect it too. -
Add 1 day to the Month of February on leap year
I know how to calculate leap year. The calculation is working great.
However, I need to add a day to the month of February if a leap year is selected.
Do you have any pointers on this?
Thanks!Thanks!
I got it
if(leapYear){
if (month==2)
numDays = numDays +1;
} -
SQL select Statement -first day and last day of the month - 1 year from now
Hi,
I need to write a SQL to get the dates in between first day and last day of the month one year from now.
SELECT last_day(add_months(sysdate,12)) as lastday from dual
What could be the Query to get the first day of the month one year from now..
ie ..Sysdate - 3-DEC-2009
Result - 1-DEC-2010
thank youHi,
You can use TRUNC with 2 arguments to get the first DATE in a month, year, quarter, week, hour, minute, ISO year, ...
SELECT TRUNC ( ADD_MONTHS ( SYSDATE
, 12
, 'MONTH'
) AS first_of_month
FROM dual
;The DATE returned will be in the same month, year, quearter, ... as the first argument.
\We convered the last day of the month in [your previous question|http://forums.oracle.com/forums/message.jspa?messageID=3942939#3942939].
At that time, I warded about using LAST_DAY as a cutoff point; TRUNC is a much better way.
For example, to find all appointment_dates in the current month next year:
SELECT *
FROM appointments
WHERE appointment_date >= TRUNC (ADD_MONTHS (SYSDATE, 12), 'MONTH')
AND appointment_date < TRUNC (ADD_MONTHS (SYSDATE, 13), 'MONTH')Note that
the first part of the WHERE clause calls for dates on or equal to the beginning of the 12th month in the future, but
the second part of the WHERE clause calls for dates before, not equal to , the beginning of the 13th month in the future. -
Customer Exit to get last day of month from Year/month
Hi Experts,
I need to create a customer exit to get the last day of month from Cal Year month input variable.
Examples
1)
User input period: 12.2008
I need from the customer exit: 31.12.2008
2)
User input period: 02.2009
I need from the customer exit: 28.02.2009
Can someone help me with the ABAP code to achieve this with a customer exit?
Help will be appreciated.Hi,
Please use the following code,
Second one is the suitable solution for you, I can understand that, if it leafe year then you have the problem so use the secon one.
First one is using Period i.e. 010.2008 (December 2008).
Secodn one is based on Date/Month.
Note: Insted of SY-DATUm, you give your variable name
*******To get the Last day of the Fy Period entered by User in ZFYP***
WHEN 'ZLDAY_FI'.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZFYP'.
zbdatj = loc_var_range-low+0(4).
zbuper = loc_var_range-low+4(3).
CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
EXPORTING
i_gjahr = zbdatj
i_periv = 'V3'
i_poper = zbuper
IMPORTING
e_date = zzdate.
CLEAR: l_s_range.
l_s_range-low = zzdate.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDLOOP.
Note: in the below code I given SY-DATUM, so you change to your Month Variable like using
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'XXXX'.
** Last Day of Current Calendar month
zzdate = sy-datum.
CALL FUNCTION '/OSP/GET_DAYS_IN_MONTH'
EXPORTING
iv_date = zzdate
IMPORTING
ev_days = znum.
CLEAR: l_s_range.
l_s_range-low+6(2) = znum.
l_s_range-low+0(4) = sy-datum+0(4).
l_s_range-low+4(2) = sy-datum+4(2).
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
Thanks
Reddy
Edited by: Surendra Reddy on Jan 27, 2009 2:47 PM
Edited by: Surendra Reddy on Jan 28, 2009 6:12 AM
Maybe you are looking for
-
Tell me Logic for search for duplicate words(or strings) in a large file.
Search for duplicate words (or strings) in a text file containing one word per line. For each word that occurs more than once in the flat file output should be as follows <word> <number of occurrences> <line numbers in the file where the word occurs>
-
Hi , I have T430 Thinkpad Notebook with the following Config : - Processor : Intel(R) Core(TM) i5-3320M CPU @ 2.6ghz -Ram :8GB -Display adapter: Intel(R) HD Graphics 4000. Express Card Slot available . OS : Window 7 enterprise 64 Bit Query : I am no
-
To create a standby controlfile, do I have to be with my database mounted in exclusive, or there is another way to do that without shutdown the database? Thanks, Rafael.
-
Sales BOM in different warehouse
Hello short question I upload productTree Sales BOM with an artcile sold in different warehouses It seems that the same article code can not be used in different places Exemple Article A sold using article B and C in stock in warehouse 01 Article A c
-
Network mac address not present in OS yosemite
HI, I have a 2012 retina MacBook Pro (Retina, 13-inch, Late 2013), 2.4 GHz Intel Core i5. I recently upgraded to Yosemite and can no longer see the mac address of my Apple usb ethernet adapter on the network setting on the system preferences applicat