How to - get first DAY of the month from the date ?
Hi
pls help
hi,
data : DAYNR LIKE HRVSCHED-DAYNR,
DAYTXT LIKE HRVSCHED-DAYTXT.
data langu like sy-langu value 'EN'.
Parameters PDATE LIKE SY-DATUM.
PDATE+6(02) = '01'.
CALL FUNCTION 'RH_GET_DATE_DAYNAME'
EXPORTING
LANGU = LANGU
DATE = PDATE
CALID =
IMPORTING
DAYNR = DAYNR
DAYTXT = DAYTXT
DAYFREE =
EXCEPTIONS
NO_LANGU = 1
NO_DATE = 2
NO_DAYTXT_FOR_LANGU = 3
INVALID_DATE = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE :/ PDATE, DAYNR, DAYTXT.
(OR)
Try..
DATA:DAYNR LIKE HRVSCHED-DAYNR,
DAYTXT LIKE HRVSCHED-DAYTXT,
DAYFREE LIKE HRVSCHED-NODAY.
DATA:LANGU LIKE SY-LANGU ,
DATE LIKE SY-DATUM,
CALID LIKE P1027-CALID VALUE 'US'.
date = sy-datum.
date+6(2) = 01. "----->to get the first day .
*first day of the month
write:/ 'First date of the month', date.
*Day name
CALL FUNCTION 'RH_GET_DATE_DAYNAME'
EXPORTING
langu = SY-LANGU
date = DATE
CALID = CALID
IMPORTING
DAYNR = DAYNR
DAYTXT = DAYTXT
DAYFREE = DAYFREE
EXCEPTIONS
NO_LANGU = 1
NO_DATE = 2
NO_DAYTXT_FOR_LANGU = 3
INVALID_DATE = 4
OTHERS = 5
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE:/ DAYTXT.
Don't forget to reward if useful....
Similar Messages
-
Function Modules to get First day of week, month, Year
Can anyone name the Function Modules for getting First day of week, month ,year.
to get first day of week use this function; WEEK_GET_FIRST_DAY
CALL FUNCTION 'WEEK_GET_FIRST_DAY'
EXPORTING
WEEK = '201107'
IMPORTING
DATE = l_date
EXCEPTIONS
WEEK_INVALID = 1
OTHERS = 2.
with DATE_COMPUTE_DAY function you can get date number in week.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
DATE = workdate
IMPORTING
DAY = day_of_week_num
EXCEPTIONS
OTHERS = 8.
CASE day_of_week_num.
WHEN 1.
hold_day_of_week = 'Monday'.
WHEN 2.
hold_day_of_week = 'Tuesday'.
WHEN 3.
hold_day_of_week = 'Wednesday'.
WHEN 4.
hold_day_of_week = 'Thursday'.
WHEN 5.
hold_day_of_week = 'Friday'.
WHEN 6.
hold_day_of_week = 'Saturday'.
WHEN 7.
hold_day_of_week = 'Sunday'.
WHEN OTHERS.
hold_day_of_week = 'invalid'.
ENDCASE. -
How to get name of the month from current date.
Hi,
How to get the name of the month from current date.
Thanks,
SenthilSethil,
Use your date(let us say Date1) instead of sy-datum.
CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
LANGUAGE = SY-LANGU
IMPORTING
RETURN_CODE =
TABLES
MONTH_NAMES = itab_month
EXCEPTIONS
MONTH_NAMES_NOT_FOUND = 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.
READ TABLE itab_month
WITH KEY MNR = date1+4(2).
itab_month-LTX will contain the value you are looking for
Good luck
Raghava -
Get the month from a date column with the calculated column
I am trying to get the month from a date field with the help of calculated column. However I get this syntax error whenever I want to submit the formula:
Error
The formula contains a syntax error or is not supported.
the default language of our site is German and [datum, von] is a date field.Hi,
I have created two columns
Current MM-YY
Calculated (calculation based on other columns)
Today
Date and Time
Current MM-YY is calculated value with formula as
=TEXT(Today,"mmmm")
But the output shows as December instead of May.
I have tried =TEXT([Datum, von];"mmmm") but no help.
I am trying to populated the column automatically with current month..ex: if its May the field should show May, next month it should show June an so on.
Any kind help is grateful.
Regards,
Pradeep -
How to get last day of a month
using pl/sql
What i need is that all members whose birthdate is in the curren month will be included as having had their birthdate regardless of the date of the month. The code i have is:
Select me607.subscriber_id
me607.mbr_dob,
** trunc(months_between (*end of current month*,me607.mbr_dob) / 12) as age
from odw.mbr607_member_expanded me607
The asterixed line is what I need to change. If I put the end of the current month (where I put 'end of current month') then all those whose birthday month is in Feb will show as having had their birthdate. So if run today, folks whose birthdate is 26-feb-2005 will show an age of 5.
When grabbing the last day of the month using visual basic I just use the first day of the subsequent month minus 1. Any assistance is appreciated..Hi,
This does what you requested:
Select me607.subscriber_id, -- Don't you need a comma here?
me607.mbr_dob,
ROUND ( MONTHS_BETWEEN ( SYSDATE
, me607.mbr_dob
/ 12
from odw.mbr607_member_expanded me607
WHERE TO_CHAR (me607.mbr_dob, 'MONTH') =
TO_CHAR (SYSDATE, 'MONTH')
;If this is run sometime in February, 2010, and mbr_dob is sometime in Febrary, 2005, then the result of MONTHS_BETWEEN will be between 59 and 61. When we divide by 12 convert that to years, that difference of up to one month becomes so small that it will be lost in the rounding.
If this isn't exactly what you need, tthen post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
Edited by: Frank Kulash on Feb 17, 2010 1:32 PM
Added explanation. -
Extract the Month from the day with Query designer ...
Hi everybody,
Is there exist a method in Query designer to extract the CalMonth (Date Month) from the CalDay ?
Thanks!
Rodolphe.take reference from this step by step doc:
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/25d98cf6-0d01-0010-0e9b-edcd4597335a -
Calculating Length of Service - Splitting out the months from the years
Hi folks,
I was wondering if anyone might have the answer to a little employee length of service conundrum. I'm trying to construct a calculation that will calculate an employee's length of service in whole Years worked only. I also need to produce a second calculation to calculate length of service in whole months worked only but with the whole years worth of months deducted from it.
For example if a persons hire date is 05-Feb-2001 the two calculations would return:
Length of service Years 7
Length of service Months 6
The following calc will generate length of service as a decimalised number:
MONTHS_BETWEEN(SYSDATE,Hire Date) /12
So for my example person I get 7.64 years.
I need to somehow round this down to the nearest 1 to get whole years service. I cannot use the ROUND function because it rounds to the nearest, so when a number is n.5 or higher it'll round up and will only round down when the number is n.49 or lower. grrr.
My next mission is to work out months service based on whats after the decimal place. If I could round the Length of service Years down I think I could achieve this. I would just do:
ROUNDDOWN(((MONTHS_BETWEEN(SYSDATE,Hire Date) /12) - (+ROUNDDOWN+(MONTHS_BETWEEN(SYSDATE,Hire Date) /12))*12)
ROUNDOWN being my non-existent function!
Any advice on this is greatly appreciated.
LloydHi,
TRUNC is the function I always use to round down. It is more flexible than FLOOR as you can use it to round down to a number of decimal places.
You should also understand that Oracle's definition of MONTHS_BETWEEN does not meet everyones expectations. For example MONTHS_BETWEEN('28-JAN-2001', '28-FEB-2001') is exactly 1 so is MONTHS_BETWEEN('31-JAN-2001', '28-FEB-2001') unless it is a leap year when it is slightly less. That's because Oracle treats the last day of the month as different when it calculates the months between 2 dates.
Rod West -
How to get first day of the month by the given date?
Now, is there function in CRM system that can get the first day of the month ?
for example:
input date is 2007/12/12, then return 2007/12/01 (the first day of month).
Thank you~Hi ping,
data: w_date type sy-datum ,
w_temp(2) type c.
w_date = '20071212'.
w_temp = w_date+6(2).
w_temp = w_temp - 1.
w_date = w_date - w_temp.
write / w_date.
Plz Reward if useful,
Mahi. -
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 first day of calendar week ?
hi,
i'm storing some calendar weeks in my database. for example 30/2013.
How can i get the first day of this week (monday)? in this case it is 22.07.2013
thx
AnjaAs far as I know we don't have a function that converts week of a year into date. So you can try something like this.
SQL> with t
2 as
3 (
4 select '30/2013' week_year
5 from dual
6 )
7 select min(dt) week_start_day
8 from (
9 select (level - 1) + to_date('01-01-' || substr(week_year, -4), 'dd-mm-yyyy') dt
10 , week_year
11 from t
12 connect
13 by level <= to_date('31-12-' || substr(week_year, -4), 'dd-mm-yyyy') -
14 to_date('01-01-' || substr(week_year, -4), 'dd-mm-yyyy') +1
15 )
16 where to_number(to_char(dt, 'iw')) = to_number(substr(week_year, 1, instr(week_year, '/')-1));
WEEK_STAR
22-JUL-13 -
How to get last day of prev month?
SELECT to_char(SYSDATE, 'MM') -1, last_day(sysdate)
FROM DUAL;
If current month is April, How to get the last day of March? Thanks.SQL> select sysdate, trunc(sysdate, 'mm') - 1 from dual ;
SYSDATE TRUNC(SYSDA
06-APR-2004 31-MAR-2004
1 row selected.
SQL> -
How to get 10th day of every month?
Hi All,
please find the below requirement , how to achive this?
" Show the Actual as a bar on a monthly frequency, with Actual costs shown as they existed on the 10th business day of each month, going back six months – the Target can be shown as a line"
Please help me out
thanks
SwapnaHI ,
implement this function in ur colum edit
EVALUATE('TRUNC(%1,''MONTH'')+09',colmn_name)
u wil get answer for this requirement
regards
srinivas -
How to determine the month from the week number?
Hi all,
in a routine i have the week number in a year and i need to find the month but i don't know the correct FM to use for this.
Is there anyone that had to face a similar problem?
I'm considering that to determine the month it will be used the first day of the week since there are weeks belonging to 2 different months...
Thank you
StefanoHi
If you have a Fiscal Year Variant determined for the week you can use function module PERIOD_DAY_DETERMINE by passing week,fiscal year and fiscal year variant for the week which will return fist and last date.So based on last data you can determine the month.
Regards
Srilaxmi -
Java - Axis2: How to get an error code / error message from the Javascript via SOAP
Hi
In our Java applicsation we call a Javascript in a Indesign CS Server using the following code:
--- SNIP BEGIN ---
// calls the remote service on the indesign server
try {
// create service
ServiceStub oIndsgnSrvStub = new
ServiceStub(sIndesignServer);
// create service parameter
ServiceStub.RunScriptParameters
oIndsgnSrvRSParams = new ServiceStub.RunScriptParameters();
// create arguments with source- and target-file for parameter
ServiceStub.IDSPScriptArg[] oIndsgnSrvSArgs = new ServiceStub.IDSPScriptArg[2];
oIndsgnSrvSArgs[0] = new
ServiceStub.IDSPScriptArg();
oIndsgnSrvSArgs[0].setName("xml-input");
oIndsgnSrvSArgs[0].setValue(sSourceFile);
oIndsgnSrvSArgs[1] = new
ServiceStub.IDSPScriptArg();
oIndsgnSrvSArgs[1].setName("output-file");
oIndsgnSrvSArgs[1].setValue(sTargetFile);
// define service parameter
oIndsgnSrvRSParams.setScriptArgs(oIndsgnSrvSArgs);
oIndsgnSrvRSParams.setScriptFile(sScriptFile);
oIndsgnSrvRSParams.setScriptLanguage("javascript");
oIndsgnSrvRSParams.setScriptText("");
// create runscript
ServiceStub.RunScript oIndsgnSrvRS = new ServiceStub.RunScript();
// set parameter
oIndsgnSrvRS.setRunScriptParameters(oIndsgnSrvRSParams);
//$$$ there should be an answer returned by the InddSrvr
// execute SOAP call
ServiceStub.RunScriptResult oIndsgnSrvRes = oIndsgnSrvStub.RunScript(oIndsgnSrvRS);
if(oIndsgnSrvRes.getErrorNumber() == 0) {
oServerProdJob.setProdState(CBP_Constant.REMOTEPRODUCTIONSTATE_SUCCESS);
bOK = true;
} else {
oServerProdJob.setProdState(CBP_Constant.REMOTEPRODUCTIONSTATE_FAILURE);
bOK = false;
//$$$ should be set, if there is something returned by inddsrvr
//oServerProdJob.setErrorMsg(sErrorMsg);
} catch(Exception e) {
sError += e.getMessage() + "\n";
bOK = false;
--- SNIP END -----
The problem is that we don't get the error code and/or the error message from the Javascript in oIndsgnSrvRes. The error code is always 0 if I set an Integer value as return in the Javascript. If I set a String, there is an Exception in the Java application.
Here is the Java script we use:
--- SNIP BEGIN ---
main();
main()
var sError = "";
var sXMLInput = "";
var sLayoutPath = "";
// get the SDKCodeSnippetRunner object
var cbpAdapter = app.cbpCbpadapterObject
if (cbpAdapter) {
sXMLInput=app.scriptArgs.get("xml-input");
sLayoutOutputFile=app.scriptArgs.get("output-file");
sError = cbpAdapter.doProcess(sXMLInput, sLayoutOutputFile);
return sError; // This give an Exception; if I return an Integer the ScriptResult is always 0
--- SNIP END -----
If I try this with the test application from Adobe I get the error code correctly. But in the Java application, using SOAP, I can't get the error code.
What could be wrong?
Any ideas?
Thanks a lot for the support.
Kind regards
Hansuser11340104 wrote:
Hello -
i am calling sqlplus from a bash shell script. If the sql statement generates an error, how can I return that error code (unsuccessful) back to the bash shell?
Well, let google be your friend,
http://www.google.co.in/search?rlz=1C1GGLS_enIN327IN327&sourceid=chrome&ie=UTF-8&q=sqlplus+error+codes
There are many threads I guess talking about the same issue.
HTH
Aman.... -
How to get status of a sub process from the parent process.
Hi,
I want to get the status of a subprocess from the parent process (i.e. success or failure).
How can I get this.
Thanks in advance.
Byehave a look at the workflow built-in vars:
WF_ACTION_ERROR and WF_ACTION_RESULT or WF_CASE_RESULT
WilfredS
Maybe you are looking for
-
Windows recongnizes one iPhone but not other
My Mom asked my help because her windows XP PC will no longer recognize her iPhone 3GS or my Dad's 3G for Photo transfer. They show up in iTunes and everything works fine there, but they don't show up anywhere else. I tried all the usual ideas regard
-
External display problem after 10.8.3 upgrade
After applying 10.8.3 Combo Updater, the external display would not wake up after the computer resume from sleep. Mac: MBP Retina 13" Late 2012 Display: Acer S230HL Connection: DisplayPort - DVI cable Please fix it Apple!
-
Exception not throwing to action class in Unix environment
Hi We are using Weblogic Server 9.2.3.0. One of our EJB is not throwing exception to calling Action class in Unix environment. Its working fine in Windows. Somehow the EJB is swallowing the exception. any idea? I suspect it may be environmental issue
-
Interconnect 10g problem with XML which has mixed contents
I'm having problem to receive a XML message which contains PCDATA and other child element Mixed. Here is the sample DTD. I'm able to create the CV and AV by importing this DTD. But at runtime, if the inbound XML contains PCDATA and other element mixe
-
Published Reports Display/Print Incorrectly
We use Crystal Reports 8.5 to create reports. The reports display and print correctly in Crystal Reports; however, when we publish the reports to be view via HTTP using Crystal Enterprise 8's publishing wizard, the reports do not display or print cor