How to subtract n years from a date
Hi all,
I need to subtract n years from a given date..
for example
if date is 21.07.200<b>6</b>.. if i want to subtract 2 years (n years) i should get 21.07.200<b>4</b>
hi,
FM.
CCM_GO_BACK_MONTHS
Example
Data : Lv_current_date type dats,
lv_new_date type dats,
lv_no_months type NUMC3.
Lv_current_date = sy-datum.
lv_no_months = 12 * 2.
CCM_GO_BACK_MONTHS
IMPORTING
CURRDATE = Lv_current_date
BACKMONTHS = lv_no_months
EXPORTING
NEWDATE = lv_new_date.
Reward Points & Mark Helpful Answers.
to reward points ;click radio button next to the post.
select radio button as per the answers.
Similar Messages
-
How to parse the year from a date.
Hi,
I have the following date format in database.
05-SEP-07
18-OCT-07
18-OCT-07
25-JUL-07
18-OCT-07
What I am trying to do is get only the full year from the date, example
2007
2008
2009
I tried to use extract function but that doesn't work due to ORA-01843: not a valid month.
Thanks in advance.
select extract(year from date '18-OCT-07') from dual;OK. You got an error using date literal. Did you at least look in documentation on date literals? I guess not, otherwise you'd see that data literal synatx is DATE 'YYYY-MM-DD':
SQL> select extract(year from date '18-OCT-07') from dual;
select extract(year from date '18-OCT-07') from dual
ERROR at line 1:
ORA-01843: not a valid month
SQL>
SQL> select extract(year from date '2007-10-18') from dual;
EXTRACT(YEARFROMDATE'2007-10-18')
2007
SQL> SY.
P.S. "I have the following date format in database" is completely wrong dates are always stored in one format - internal date format that stores year, month, day, hour, minute and second. When you select date using client tools like SQL*Plus, SQL Developer, Toad, etc. date is converted to string using either explicit or implicit format where you specify which parts of date you want to see. -
How do I pull just the year from a date?
I'm trying to pull just the year from a date and cannot figure out how this can be done. I tried the SUBSTR fuction but its not acting how I would expect. What I'm wanting to do is write a condition that says Item Birth Year = Current Year minus 23 I have a calc that figures the age from the difference in the birthdate and current year but I'd really like to just write a condition based just one years. Can this be done?
Hello
SUBSTR will only work on a string. To extract portions of a date you need to use the TO_CHAR command.
To get the year you would use this: TO_CHAR(the_date,'YYYY')
TO_CHAR takes 2 switches, the date to be manipulated and the portion to be extracted, with the portion in single quotes.
Once you get used to manipulating dates like this other common pieces are: DD - extracts the day of the month, MON extracts the 3 character code for the month.
Thus you can use this: TO_CHAR(sysdate,'DD-MON-YYYY') and it will convert the current date, June 7th 2012 to 07-JUN-2012
Hope this helps
Best wishes
Michael -
How do i extract year from a variable???
Hi all,
I want to extract year from a parameter.
I tried the following, i'm getting errors.
When I executed the below code,
SELECT TO_CHAR(:X_PRM_YR_END_DT,'YYYY') FROM dual;
I got the following error.
ORA-01722:invalid number
When I executed the below code,
SELECT TO_DATE(:X_PRM_YR_END_DT,'YYYY') FROM dual;
SELECT to_char(TO_DATE(:X_PRM_YR_END_DT,'YYYY')) FROM dual;
I got the following error.
ORA-01830: date format end before converting entire input string
When I executed the below code,
SELECT extract(YEAR FROM :X_PRM_YR_END_DT) FROM dual;
SELECT extract(YEAR FROM 1/11/2013) FROM dual;
I got the following error.
ORA-30076: invalid extract field for extract source
How do i extract year from a variable???
Help me plz
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production.Try This,
select TO_CHAR(to_date('01/01/1980','dd/mm/yyyy'),'YYYY') FROM dual; -
Read Year from System Date & Compare - Assistance required
Hi All,
I am trying to read only the year part from the system date & then checking if any entry exists in EKKO table (EKKO-BEDAT) for the year. I think i am making an error in my data declaration for V_YEAR & in my select statement (EKKO~BEDAT LIKE V_YEAR), not sure how to compare only the year part, can someone help.
DATA:
V_EBELN TYPE EKPO-EBELN,
V_YEAR TYPE SY-DATUM.
CLEAR: V_EBELN, V_YEAR.
*Read year from system date
V_YEAR = SY-DATUM+0(4).
CONCATENATE '%' '%' '%' '%' V_YEAR INTO V_YEAR.
*Select section
SELECT SINGLE EKPO~EBELN INTO V_EBELN
FROM EKPO
INNER JOIN EKKO
ON EKPOEBELN = EKKOEBELN
INNER JOIN LFM1
ON EKKOLIFNR = LFM1LIFNR
WHERE EKKO~LIFNR = LFM1-LIFNR
AND EKKO~BEDAT LIKE V_YEAR
AND EKPO~LOEKZ = SPACE.Hi Sougata,
Thanks for the inputs, but it is not working:
Move: sy-datum(4) to v_begda, -> This reads the system year 2008
'0101' to v_begda, -> This changes 2008 to 0101
sy-datum(4) to v_endda, -> This reads system year i.e. 2008
'1231' to v_endda. -> This changes 2008 to 1231
Also in the select statement
AND EKKO~BEDAT between v_begda and v_endda
This would not work, as EKKO-BEDAT is in year month date format.
So can you please clarify why we are assigining 0101 & 1231 & also how we can compare only the year in EKKO-BEDAT with System Year
Update
I tried to
concatenate '0101 into v_begda.
concatenate '1231' into v_endda.
but system prompts "charlike-field" expected after "'0101'"
Can you please advice?
Edited by: Vivek on Jan 5, 2008 7:59 PM -
How to get maximal value from the data/class for show in Map legend
I make WAD report that using Map Web Item.
I devide to four (4) classes for legend (Generate_Breaks).
I want to change default value for the class by javascript and for this,
I need to get maximal value from the class.
How to get maximal value from the data/class.
please give me solution for my problem.
Many Thx
Eddy Utomouse this to get the following End_date
<?following-sibling::../END_DATE?>
Try this
<?for-each:/ROOT/ROW?>
==================
Current StartDate <?START_DATE?>
Current End Date <?END_DATE?>
Next Start Date <?following-sibling::ROW/END_DATE?>
Previous End Date <?preceding-sibling::ROW[1]/END_DATE?>
================
<?end for-each?>
o/p
==================
Current StartDate 01-01-1980
Current End Date 01-01-1988
Next Start Date 01-01-1990
Previous End Date
================
==================
Current StartDate 01-01-1988
Current End Date 01-01-1990
Next Start Date 01-01-2005
Previous End Date 01-01-1988
================
==================
Current StartDate 01-01-2000
Current End Date 01-01-2005
Next Start Date
Previous End Date 01 -
How to get internal table from SAP Data Provider C#
Hello.
ABAP:
DATA: lt_t001 TYPE TABLE OF t001.
DATA: url(1000) TYPE c.
SELECT * INTO TABLE lt_t001 FROM t001.
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'APPLICATION'
subtype = 'X-R3TABLE'
TABLES
data = lt_t001
CHANGING
url = url
EXCEPTIONS
OTHERS = 4.
C#:
using SAPDataProvider;
using SAPTableFactoryCtrl;
public void SetDataFromUrl(string url)
SAPDataProviderClass p = new SAPDataProviderClass();
p.SetDataFromURL("APPLICATION", "X-R3TABLE", url);
ISapDPR3Table tbl = p.GetDataAsR3Table("APPLICATION", "X-R3TABLE");
SAPTableFactoryClass tf = new SAPTableFactoryClass();
Table tb = (Table)tf.NewTable();
tb.ISAPrfcITab = tbl.DataTable; // Exception !!!!!!
How to get internal table from SAP Data Provider ?Hi Sergey,
I'm trying to do the same, have you found a solution to solved it?
thanks for your help.
Regards.
Jonathan -
How to subtract a day from the presentation variable @{system.currentTime}
Hello,
How can subtract a day from the presentation variable - @{system.currentTime}
I use the above as a title in the report. However I want to subtract a day from the above variable. How can I accomplish it?
Thanks.Hi,
Did you try the steps which I mentioned above. You can use TIMESTAMPADD function in many places in your report but I think not in title section of the title view.
Also you can try using Narrative view instead of title view to achieve this. Follow below steos:
* Pull another column in the report and change its fx to TIMESTAMPADD(SQL_TSI_DAY, -1, @{system.currentTime})
* Now go to the Narrative view and add the below text in Narrative section of the view.
Active Person Report as of @1
Here @1 assuming the new column created is placed before all the columns in the request.
* Also set the 'Rows to Display' as 1.
* Delete Title view from the report and this narrative view on top of your report.
Hope this helps.
Thanks -
How can I take minutes from mysql date format
how can I take minutes from mysql date format??
example 10:30:00 is stored in my sql and I want to create 3 variables which will store hours, minutes and seconds..
Cheers.."use application date format" is the choice you want.
Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.opal-consulting.de/training
http://apex.oracle.com/pls/otn/f?p=31517:1
http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
------------------------------------------------------------------- -
Extracting Year from the date field
Hi,
I want to extract year from the date field... I've tried following code but got the error
SELECT to_char(a.A_EXPIRY_DATE,'yyyy') as EXP_YEAR from Table_A a
Please advice
Thanks in advanceuser12863454 wrote:
SELECT to_char(a.A_EXPIRY_DATE,'yyyy') as EXP_YEAR from Table_A aThis should work and returns a string.
What error did you get?
maybe your column name is wrong? Is it really A_somthing? This is possible but slightly unusual.
also possible
select extract(Year from sysdate) from dual;
/* with your table and column */
SELECT extract(year from a.A_EXPIRY_DATE) as EXP_YEAR from Table_A a;Edited by: Sven W. on Aug 18, 2010 6:41 PM -
Getting the year from the date field
Hi,
Please ltet me know how to get only YEAR form the DATE field
Thanks in advance
Ajaydata:
date like sy-datum,
year(4) type c,
month(2) type c,
day(2) type c.
year = date(4).
month = date+4(2).
day = date+6(2).
Regards,
Michael
Please mark question as anwered if so.... -
How to calculate week number from system date
Hi experts,
how to calculate week number from system date ?
thanks.
SKhi,
The above FM can be used for BADI or customer exit, if it is design level then you can use formula as well, under formula date functions you can use DATE_TO_WEEK.
regards,
Arvind. -
How to derive month/year from date in SAP BW 3.5 data flow
Hi
How we can derive cal year/month and fiscal month/year from date in SAP BW 3.5 data flow (we're using transfer and update rule)..
Thanks,
PKHi,
if you have any date filed in source side you can just map to any time char system will automatically convert to target objects.
please look at the screen shot for understanding. (not 3.x it is 7.x)
Thanks,
Phani. -
How to get the week number of year from a Date object?
Hi!
I would like to know the week number of the year from a specified Date.
I dont know how to set the first day of week, and set the minimum days of a week.
I want to use Monday for first day of week, and at least 4 days of month in a week.
For example if its 1st, January is Friday, then the first week starts on 4th, Monday.
Anyone can help?Sorry. I should think before I move.
public static int getWeekOfYear(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.setMinimalDaysInFirstWeek(4);
return calendar.get(Calendar.WEEK_OF_YEAR);
} -
XSLT Mapping: how to calculate Week number of the year from given date
Hi,
I have input as date, i need to know the Week number from that date in XSLT Coding.
for Eg: if date is 29-12-2009 it should give 53rd week of the year.
All answers will be appreciated.
Regards,
MayankHi add this statement to your XSLT Mappping
<xsl:stylesheet version="1.0" xmlns:java="http://xml.apache.org/xslt/java" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="java">
and use <xsl:template name="GetDateInLocal" xmlns:cal="xalan://java.util.GregorianCalendar"> in XSLT Mapping , write your logic.
cheers,
Raj
Maybe you are looking for
-
StarSuite will not start up - help! Changed paths from one drive to another
Hi all, I am using: StarSuite 8 On an: ASUS eePC 900 OS: Windows XP This is my partner's computer. StarSuite 8 came with it the machine, but as yet she has not even gotten a chance to use it. It has two hard drives: C: drive is 4GB (with 500MG free),
-
Remove Sort in Pivot Table View
Hi Folks, How to remove sort options from column header on pivot table view? Thanks, Aj
-
Secure the file/data transfer between XI and any third-party system
Hi All,, I would like to use to "secure" SSH on OS Level the file/data transfer between XI and any third-party system Run OS Command before processing and OS command After processing. right now my XI server installed on iSeries OS. with ISeries we ca
-
Leave the charger on all the time?
Is it wise to leave the charger on during the night while I'm not using the mac? Should I unplug the charger and get it back on the next day. I take the Mac to school and don't use the charger while I'm there.
-
after down loading the new i yunes update i get the message to re install MSVCR80.dll I can not open i tunes at all. What to do?