Date to Elapsed Days Conversion
Hello Guys
I need guidance in Date to Days Conversion
Lets Suppose i have a string as following
var time:String = "2009-09-01"
and as today is 5
so i want a value like
"4 Days Ago"
How could i convert this date to days?
Thanks in advance
Hi,
First compare this with previous records, i think there is some wrong input, for this type of fiscal Period u can use PERI7 Conversion Routine.
http://help.sap.com/saphelp_nw04/helpdata/en/3f/e2e32d7e612d4eb4f610b2674af40b/content.htm
Hope it helps.
Regards
Siddhu
Similar Messages
-
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 -
Increasing the date by 30 days
Hello all,
Thanks for taking the time to read this message.
I am getting the date as a string from the registry entry, in this format yyyyMMddHHmmss.
I would like to add 30 days to this again set it in the registry, I know how to set it in the registry, but dont know how i can increase this date by 30 days.
I know how to increase it from the current time ..like this.
new Date(System.currentTimeMillis() + (30L * 24L * 60L * 60L * 1000L));
but dont know how to increase from the taken time.
hope you understand my question.
ThanksCalendar.add()Thanks for the reply. I have absolutely no idea what
you just said, it would be great if you could give me
an example.Click [url http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html#add(int, int)]here.
Or here...
Calculating Java dates: Take the time to learn how to create and use dates
Working in Java time: Learn the basics of calculating elapsed time in Java
Formatting a Date Using a Custom Format
Parsing a Date Using a Custom Format -
Hi Community,
I have posted this question in Acrobat.Answers.com
Count Elapsed Days (JavaScript)
The script provided there is almost works. But If SaleesDate is Jan 1, then this is showing wrong output. ie;
Jan 1, 2014 showing 3366, but should be 41. Only issue if Date is Jan 1.
Also i have two more request on this same.
1. If SalesDate is empty, then show as empty.
2. Always use 000 format in elapsed days. so need to show like 001, 010, 100. So with Lastdigit is like 4001, 4010, 4100
Thanks a lot for your valuable time.
Thank you
AdobeFanThere are a number of trip points here.
Try the following script for the year and elapsed number of days field:
function GetField(cName) {
// get field object with error checking;
var oField = this.getField(cName);
if(oField == null) app.alert("Error accessing field named " + cName + "\nPlease check that this is the correct field name.", 1, 0);
return oField;
} // end GetField function;
function Scand(cFormat, cDateString) {
// using format convert date string to date object with error checking;
var oDate = util.scand(cFormat, cDateString);
if(oDate == null) app.alert("Error converting date " + cDateString + " with format of " + cFormat + "\nPlease check date string and date formatting.", 1, 0);
return oDate;
} // end Scand function;
event.value = ""; // clear the result field;
var cFieldName = "SalesDate"; // field name;
var oSalesField = GetField(cFieldName); // get field object;
if(oSalesField != null && oSalesField.valueAsString != "") {
oSalesDate = Scand("dd-mmmm-yyyy", oSalesField.valueAsString); // convert date string to date object;
// console.println(oSalesDate + " sales date");
var oStartDate = Scand("yyyy-mm-dd", oSalesDate.getFullYear() + "-01-01"); // date object for 1-jan for year of sale;
// console.println(oStartDate + " Start date");
var nDiff = oSalesDate.getTime() - oStartDate.getTime(); //elapsed milliseconds;
nDiff = Math.ceil(nDiff / (1000 * 60 * 60 * 24)) + 1; // days inlcuding last day;
// console.println(nDiff);
// set field value inlcude last digit of year and elapsed days;
event.value = String(oSalesDate.getFullYear()).substr(3,1) + util.printf("%,103.0f", nDiff);
One has to count the start day as a full day and then there is the 3 leading zero formatting. -
We developed a SSIS Package to pull the data From Oracle source to Sql Server 2012. Here we used ADO.Net source to pull the records from Source but getting the below error after pulling some 40K records.
[ADO NET Source [2]] Error: The ADO NET Source was unable to process the data. ORA-64203: Destination buffer too small to hold CLOB data after character set conversion.
[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.
The PrimeOutput method on ADO NET Source returned error code 0xC02090F5.
The component returned a failure code when the pipeline engine called PrimeOutput().
The meaning of the failure code is defined by the component,
but the error is fatal and the pipeline stopped executing.
There may be error messages posted before this with more
information about the failure.
Anything that we can do to fix this?Hi,
Tried both....
* Having schema type as Nvarchar(max). - Getting the same error.
* Instead of ADO.Net Source used OLEDB Source with driver as " Oracle Provide for OLE DB" Getting error as below.
[OLE DB Source [478]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on OLE DB Source returned error code 0xC0202009. The component returned a failure
code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the
failure.
Additional Info:
* Here the Source task is getting failed not the conversion or destination task.
Thanks,
Loganathan A. -
How to get the date of first day of a week for a given date
Hi gurus
can any one say me how to get the date of first day(date of Sunday) of a week for a given date in a BW transformations. For example for 02/23/2012 in source i need to get 02/19/2012(Sunday`s date) date in the result. I can get that start date of a week using BWSO_DATE_GET_FIRST_WEEKDAY function module. But this function module retrieves me the start date as weeks monday(02/20/2012) date. But i need sundays(02/19/2012) date as the start date. So it would be really great if anyone sends me the solution.
Thanks
RavHi,
The simplest way would be to subtract 1 from the date date which you are already getting in transformation routine, but instead of doing that subtraction manually which might need bit of errort, you can simply use another FM to subtract 1 from given date.
RP_CALC_DATE_IN_INTERVAL
Regards,
Durgesh. -
Date for first day of current month
How can i get the date for first day of current month ?
select trunc(sysdate,'MM'),to_char(trunc(sysdate,'MM'),'DD'),to_char(trunc(sysdate,'MM'),'Day') from dual;
-
Show data of last day of previous month against any day of current month
Hi,
I have fact table which contains data at date level (we have data for oct-2009 to april-2010). Our requirement is to show data of last day of previous month against any day of current month in obiee 11g. I am facing problem in Feb 2010 its picking data of 28-Jan-2010 instead of 31-jan-2010 and for April its picking data of 30-mar-2010 instead of 31-mar -2010.
Any suggestion ???You're asking to filter your data set to only include rows between:
1) last day of the previous month
2) any day of the current month
This can be achieved with prompting in OBIEE Answers.
last day of previous month = TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) . The problem is you need to make query work within Oracle's Answer syntax.
In the prompt, select the operator type for your date dimension as 'between' and default to 'SQL Results'.
For the 'last day of previous month' , use the query:
SELECT
case when 1=0 then Time."Fiscal Date" else TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
end
FROM ENTER_YOUR_PRESENTATION_FACT_FOLDER_HERE
For the current date, use the query:
SELECT
case when 1=0 then Time."Fiscal Date" else CURRENT_DATE
end
FROM ENTER_YOUR_PRESENTATION_FACT_FOLDER_HERE
Another option is to create a last_date_pervious_month variable in the RPD and have that as the default value in your prompt. -
Hello,
I am using oracle8i. The date format is not giving the proper date values in XML conversion..
create table test(dt date);
insert into test values(sysdate);
insert into test values(sysdate);
insert into test values(sysdate);
TEST.WORLD> select * from test;
DT
28-NOV-04
28-NOV-04
28-NOV-04
set autoprint on
set long 100000
set linesize 100000
set longchunksize 100000
var g_clob clob
declare
l_ctx dbms_xmlquery.ctxType;
l_clob clob;
begin
l_ctx := dbms_xmlquery.newContext('select dt from test');
dbms_lob.createtemporary(:g_clob,true,dbms_lob.session);
dbms_xmlquery.setdateformat(l_ctx,'yyyy-mm-dd');
:g_clob := dbms_xmlquery.getXml(l_ctx);
end;
Here is the output . It is dispalying the 03 For the month november.
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<DT>2004-03-28</DT>
</ROW>
<ROW num="2">
<DT>2004-03-28</DT>
</ROW>
<ROW num="3">
<DT>2004-03-28</DT>
</ROW>
</ROWSET>When you call DBMS_XMLQUERY.SETDATEFORMAT, you must supply the mask using the syntax defined by java.text.SimpleDateFormat.
You need to use "yyyy-MM-dd".
In your case, "yyyy-mm-dd", the lower case "mm" is the mask for minutes. -
How to get the date of 60 days before 1999/03/01?
Hi, I have a question about Date and GregorianCalendar here. I have a string "1999/03/01" and I would like to know the date that 60 days before 1999/03/01. What should I do it?
I only went this far:
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
String date = "1999/03/01";
Date day = dateFormat.parse(date);
GregorianCalendar calendar = new GregorianCalendar();
: <--- ??
So, can anyone please tell me what should I do next??
-jxchouPut this in the search box for this forum at the right: add days +date
The first 2 hits are about your question.
The Forum search is your friend... -
How to convert Date format into day in ssrs reports?
Hi
How to convert date format into day?
10/01/2010 as like Monday like that?=weekdayname(datepart("w",Fields!mydate.Value))
-Vaibhav Chaudhari -
Current date - user entered days
Hi all
I have this scenario:
I have safety stored as attribute of material.
I have to do some calculation based on this so i created a replacement path variable and used replace with attribute value.
Now i have 2 safety stock:
1. Current ( safety stock restricted to current date )
2. Safety stock Past : restricted to (current date - User entered no of Days).
How to calculate the second one in 2004s??
ThanksHi Srini
Thanks for quick response. here is the issue. The safey stock needs to be calucated for just that day. so it not aggregated from current date- user entered days to current date.
ex:
Current Safety Stock (10/26/2007) Safety past (10 /26/2007 - 7 days) ( user enters 7 days)
100 200
So how to restrict Safety past to the date which is current - user enetered no of days.
Thanks
Pankaj -
The Basic Finish date is a Day earlier than Planned date
Dear Experts,
I am getting a strange behaviour about Maintenance order Basic Finish Date when generated from Maintenance Plan. I have Customizing settings (TCode : OPU7) Adjust: "Adjust Basic dates, adjust dep reqmts to order start date" and scheduling type : Backwards in Time. For this setting Order Basic Finish Date is a day earlier than Planned date , but when Schduling type is Backwards instead of Backwards in Time, Basic Finish date is same as Planned date.
Example: The start of cycle of a monthly plan is 14-Nov-2010, 1st Planned date is 14-Dec-2010. When Scheduling type is " Backwards in time" , the order generated is having Basic Finish Date as 13-Dec-2010 .And when Scheduling type is "Backwards" , Basic finish date is 14-Dec-2010.
Thank you.
-Malay-Hi there,
Please check the primilinairy buffer in your strategy package. This field have an effect on your order start date.
But I agree on Pete, you should use a forward planning.
Regards,
Johan
Edited by: Johan Zeeman on Dec 17, 2010 11:29 AM -
Hi,
I have CURRENT DAY variable and i want to create one more variable which gives the Date before 30 days.
Is there any STD variable which gives the date before 30 days .Please tell me.
I have created one variable with Customer exit processing type and i need to develop code for this. Can anybody provide code how we will get date(dd/mm/yyyy) before 30 days .I have created variable with name "Z_CVAR". Please help me on this.use 0date variable to get the system date ... which is the SAP standard variable which pics the sy-datum.
Next restrict the KF with the 0date and right click on the 0date and click on offset and set the off set for the varaible as -30.
which gives the value -30 days.
If not as suggested in the earlier post -- create a z variable with replacement path -customer exit -- write the code ... in the code itself write the logic to get the -30 days
IF i_step = 2.
CASE i_vnam.
WHEN 'ZCURDAY-30'.
CLEAR: l_s_range.
l_s_range-low = sy-datum -30.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDCASE.
ENDIF.
regards
KP -
Figure out dates corresponding to days of the week, constructing a schedule
Hi everyone,
I'm sorry if this topic has already been covered. I've searched the forums for an answer, but did not see anything I took to be an answer (I'm not very good at this).
I'm trying to make a simple table to tell me which dates a particular day of the week falls on. For instance, I'm making a syllabus for a class that meets every Tuesday and Thursday. I want to know which dates corresponds to every Tuesday and Thursday from here on out.
I currently have a table with two columns. The first column is the day of the week. The first row is Tuesday, the second is Thursday, the third Tuesday, etc. I was able to do this easily with auto fill. I want the next column to be the date.
Here's a picture of what I mean:
Is there a formula that will let me do this?
Thanks!Hi Macademic,
How about putting both into the first column?
Select all of column A and use the Cell Format inspector to set the format as Date and Time, with the Date: and Time: pop-up menus set to:
Date: Mon, Jan 5, 2009
or: Monday, January 5, 2009
or to a Custom format, Date and Time, including only the elements you want in the format you want them.
Time: None
Enter the starting date into A2, and confirm that it is either a Tuesday or a Thursday.
In A3, enter
=A2+2 (if the course starts on a Tuesday)
or
=A2+5 (if the course starts on a Thursday)
In A4, enter
=A2+7
Select A3 and A4, then grab the control (small circle at the lower right corner of the selection) and drag down until you reach the last date of the course.
Regards,
Barry
Maybe you are looking for
-
EHP4 Upgrade ABAP+JAVA stack
Hi SDN Team, We are in the proceess of EHP4 upgrade,now we are at the road map configuration where we got stuck,I is looking for JAVA sca files in XML file but could not found the same and it throw an error, Trouble Ticket Log =============== Trouble
-
Reinstalling Tiger- what are my options?
My whole system is slowly falling apart, bit by bit. It started with little bugs here and there, but with each day it gets worse. Disk utility won't open, my battery/volume/time/airport status displays don't update, iPhoto crashes whenever I try to e
-
Permitting user to choose value for a field only from F4
Hi all, I have the following requirement in table maintenance generator. There is a custom field in the Z table for which table maintenance is generated to which a search help is attached. Now in the maintenance screen(SM30) i get a F4 value
-
Search Example-PGM BAPI_CONTRACT_CREATEFROMDATA
Hallo, who could provide a demo program with FUBA "BAPI_CONTRACT_CREATEFROMDATA" for the generation of SD-Contracts (VA41). My utility (procedure, program) only generates the text: "Vendor(selling) receipt still incomplete ... Furthermore I would li
-
Can we capture and filter out wavelengths with the camera?
Hi, I don't know if somebody can answer this, but is there a method to filter out wavelengths using the lumia camera and capture them? This capability could be applied in the field of biophotonics. So e.g. you make an app that sets the camera to only