Required help on date functions
Hi All,
Any body give some idea to add start_date abd duration in the below
SELECT hruserdt.get_table_value ( 346 , 'APPRAISAL_SETUP' , 'NOTIFICATION' ,'PLAN' , SYSDATE ) as start_date ,
hruserdt.get_table_value ( 346 , 'APPRAISAL_SETUP' , 'DURATION' ,'PLAN' , SYSDATE ) as duration from dual
start_date : 01-Dec-2008
Duration: 365
Thanks,
UMA
Uma Maddi wrote:
Duration: 365Assuming 365 is number of days:
SELECT hruserdt.get_table_value(346,'APPRAISAL_SETUP','NOTIFICATION','PLAN',SYSDATE) as start_date,
hruserdt.get_table_value(346,'APPRAISAL_SETUP','DURATION','PLAN',SYSDATE) as duration,
hruserdt.get_table_value(346,'APPRAISAL_SETUP','NOTIFICATION','PLAN',SYSDATE) +
hruserdt.get_table_value(346,'APPRAISAL_SETUP','DURATION','PLAN',SYSDATE) as end_date
from dual
/If it is number of hours:
SELECT hruserdt.get_table_value(346,'APPRAISAL_SETUP','NOTIFICATION','PLAN',SYSDATE) as start_date,
hruserdt.get_table_value(346,'APPRAISAL_SETUP','DURATION','PLAN',SYSDATE) as duration,
hruserdt.get_table_value(346,'APPRAISAL_SETUP','NOTIFICATION','PLAN',SYSDATE) +
hruserdt.get_table_value(346,'APPRAISAL_SETUP','DURATION','PLAN',SYSDATE)/24 as end_date
from dual
/SY.
Similar Messages
-
Help with Date function in sql query....
My question I guess is really 2...I'm trying to use the date function as a comparison in my WHERE clause in my sql command.
1. My date format is dd-MMM-yy eg. (01-Apr-06) ... my problem is the Apr is lower case where my field in the database is 01-APR-06 so when I compare 01-Apr-06 to 01-APR-06 is doesnt find any rows. Is there away that I can make the Apr all upper case so that it is APR.
2. My second problem is getting this "date" field to work in my sql stmt I keep getting errors and it works fine if I take my attempts at trying to compare the date.
--------------Date Code----------------------------------------------------------
<%!
String getFormattedDate(java.util.Date d)
SimpleDateFormat simpleDate = new SimpleDateFormat("01-MMM-yy");
return simpleDate.format(d);
%>
<%
java.util.Date d = new java.util.Date();
String dateString = getFormattedDate (d);
%>
---------------------------Sql statment------------------------------------------
ResultSet rset = stmt.executeQuery ("SELECT name " + " FROM table where rdate = '01-APR-06' order by name ");
Currently Im just hard coding the date but I need to make it so it uses the date code...so....
rdate should equal the date from the formatted date in upper case
something like
rdate = <%= dateString %>
Thanks in advance for any ideas anyone may have...There are sql functions upper & lower.
SELECT name FROM table where upper(rdate) = '01-APR-06' order by name Or you could convert the date to a string, and use the toUpperCase & toLowerCase java.lang.String methods. It doesn't make much of a difference--do you want the java compiler to do the string conversion or the database? -
Help with Date Functions in BPEL
We are trying to use the following function :
xp20:subtract-dayTimeDuration-from-dateTime(dateTime as string, duration as string)
We tried duration as "01:00:00" or even a numeric value as a string like "600".
This function however does not return anything (Not even an error).
We want to subtract a certain amount of time (say x hours or minutes) from a given date/time field. Is there any other way this can be done? Or Can someone who has used this function successfully please tell us where we could have gone wrong?
Thanks
Vinod.Has anyone faced the same problem? Is there any work around to this?
Regards,
Vinod. -
hi i would like to built currect and yago sales report and unable to ge the yago correctly
report parameter p_date in format MM-YYYY
my report displays sales of 06-2010 for current and for yaga it should 06-2009
how to get get yago date
please advice
thanks/nhmShould one assume
yago means year ago
If so why don't you write year ago?
Please always write correct and complete words!
Do not write 'currect' if you mean to say 'Current'
Remember no one in Nouvion could understand officer Crabtree saying 'Git murning'.
Now as to your homework
select to_char(sysdate,'MM-YYYY'), to_char(add_months(sysdate,-12),'MM-YYYY') from dual;
This is assuming 'yago' means 'year ago'.
Sybrand Bakke
Senior Oracle DBA -
Required help with date format
Hi All,
I am calling a webservice from plsql, for this I am using UTL_DBWS package. I want to insert the format of date as 'YYYY-MM-DD' only. I used to_char(sysdate, 'YYYY-MM-DD') , but it is throwing error. Please suggest any solution.
Thanks and Regards,
Mahesh
The error details are as follows
ORA-29532: Java call terminated by uncaught Java exception: javax.xml.rpc.soap.SOAPFaultException
Caught exception while handling request: invalid date: 25-NOV-08
ORA-06512: at "SYS.UTL_DBWS", line 403
ORA-06512: at "SYS.UTL_DBWS", line 400user6391695 wrote:
Hi All,
I am calling a webservice from plsql, for this I am using UTL_DBWS package. I want to insert the format of date as 'YYYY-MM-DD' only. I used to_char(sysdate, 'YYYY-MM-DD') , but it is throwing error. Please suggest any solution.What happens is...
You convert sysdate into a string of the format YYYY-MM-DD and then you are passing that to a parameter that is a DATE datatype. When you do this oracle has to implicitly conver the string to the DATE datatype. It does this based on the NLS settings of the session which, I would guess, are not of the format YYYY-MM-DD, so it can't understand the string you have passed and fails to convert it to a date.
Date formats are not something that is stored on the database (assuming you are correctly storing dates as DATE datatype). The format of dates is a display issue and something that should be handled by the user interface. The database stores data, just that, no display formats. ;) -
can some one tell the difference between the given 2 sql statements .
1.trunc(ps.DISCH_DTTM) - trunc(ps.admit_dttm) >= 2
and
2. (ps.DISCH_DTTM - ps.admit_dttm) >= 2
which one will give me the result which has more then or equal to 48 hours of time period that is complete 2 days .
Thanks In advance .Why not try out the different variants?
WITH t1 AS (SELECT TO_DATE('01.01.2006 00:00', 'dd.mm.yyyy hh24:mi') + ((ROWNUM - 1) / 24) beg_date
FROM user_objects
WHERE ROWNUM <= 3),
t2 AS (SELECT 2 + ((ROWNUM - 3) / (24 * 60)) days
FROM user_objects
WHERE ROWNUM <= 4)
SELECT ps.*,
TRUNC(ps.DISCH_DTTM) - TRUNC(ps.admit_dttm) v1,
(ps.DISCH_DTTM - ps.admit_dttm) v2
FROM (SELECT beg_date admit_dttm, days * 24 hours, beg_date + days disch_dttm
FROM t1, t2
) ps
;That should give you a test case and an idea what results you can expect with the different versions of date subtraction.
C. -
Hi Experts,
I have an requirement related to date function in WebI.
I am working on BO 4.2 version.From the source system,I am getting the data for start date and end date.And now I need to maintain additional two more columns i.e one column is MONTHS and other column is DAYS.
Lets Say :
Start Date : 01 January,2014 = 01-01-2014
End Date : 05 April,2014 = 05-04-2014
For the above example , In the report output , it should display as :
START DATE END DATE MONTHS DAYS
01-01-2014 05-04-2014 3 4
Could anyone please let me know , which date function do I need to use in the formula, to achieve the above requirement?
Appreciate for your quick response.Thanks in advancev_dayDifference=DaysBetween([Start Date];[End Date])
v_Month=Floor([v_dayDifference]/30)
v_Days=([v_dayDifference]-[v_Month]*30)
This will give you the output like below:
Start Date
End Date
v_Month
v_Days
01 Feb, 2014
02 Mar, 2014
0
29
01 Jan, 2014
01 Jan, 2014
0
0
01 Jan, 2014
05 Apr, 2014
3
4
01 Jan, 2014
31 Jan, 2014
1
0
05 Jan, 2014
01 Apr, 2014
2
26
31 Jan, 2014
01 Feb, 2014
0
1 -
To upload a data into SAP Table with the help of RFC function in BODS
Hi,
Please provide me step-by-step solution to upload data into any SAP table with the help of RFC function in Data Services.
I have created RFC function that upload data into SAP table. RFC Function contains one table that has same structure as my database table.
In the data services how can i filled the table of RFC function, i am using this function in query transform of data services but it gives me error.
I am also follow link http://wiki.sdn.sap.com/wiki/display/BOBJ/BusinessObjectsDataServicesTipsand+Tricks
but it did not help me.
Thanks,
AbhishekHi Abhishek,
Did you import the function module in the SAP datastore first? When you open the SAP datastore, the function should be listed in the 'functions' section. If not, import it. Make sure your function is remote executable.
Once the function is there, you can use it in a transformation. In 'Schema Out' right-click on 'Query' (top level) and choose 'New Function Call'. You can then select a datastore and a function in the datastore. The wizard will show you which output parameters are available. I believe you have to add at least one and can select as many as you like.
After confirming your selection the function and the output parameters appear in Schema Out. You can then right-click on the function and choose 'Modify function call'. A popup will appear where you can specify the input parameters.
I hope this helps.
Jan. -
Hi! pls help date functions
hi! i have problem in date functions in java!
1. if i give input date format is dd/mm/yyyyy (or) yyyy/mm/dd (or) mm/dd/yyyy?
the result must be display dd/mm/yyyy only?
pls help me!
thanks and regadrs
senthilrajhttp://www.javaalmanac.com/egs/java.text/FormatDate.html
http://www.javaalmanac.com/egs/java.text/ParseDate.html -
Need milli seconds part in XSLT Date Function current-dateTime()
Hi All,
I am calling date function, current-dateTime() in XSL. The output format is 2012-04-05T16:38:01-07:00 (Without milli seconds)
How to get the milli seconds part...?
Regards,
SudheerHi Arik....
At last i got it. :)
Followed the below steps.
Step1:
Created a String variable "currentDateTimeValue" in BPEL.
Step2:
I have used the below code in JavaEmbedding in BPEL.
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat();
//Date Pattern looks lil weird. But some Web service accepts only this format.
sdf.applyPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'-00:00'");//2012-04-14T16:24:00.578-00:00
String formattedDate = sdf.format(new java.util.Date());
addAuditTrailEntry("Formatted datetime string is: " + formattedDate);
setVariableData("currentDateTimeValue", formattedDate);
Step3:
Created a Simple XSD with an element "DateElement" of String type.
Step4:
Assigned "currentDateTimeValue" value to "DateElement" element, in Assign activity.
Step5:
Now added this DateElement in Transformation activity, as a second source variable. Mapped this data to the required target element in my XSL.
uh-huh I got the output...
Thanks a ton ARIK :D u r really helpful...
Regards,
Sudheer -
Date Functions in Discoverer Query
Hi,
It has been a while since I logged into the forum. Sorry at present my contribution is only to get help. Hope to help others in future.
Here is teh problem I am facing.
We have frequent requirement to get the sales comparison by last year to this year
in Week to Date, Month to Date, Year to Date timeline.
To accomplish I use Custom Date functions in my Discoverer which results in query like below
SELECT o100229.curr_division_code,
SUM (DECODE (discotw_admin.fiscal_cal_by_wk.flyrweek (:fyrweek),
o100059.fiscal_year_week, o100341.tot_lines_ext_i_s_avg_cst,
0
The "discotw_admin.fiscal_cal_by_wk.flyrweek (:fyrweek)" is the function I use to get the Last year week number nased on the parameter for this week number.
But the problem with this approach is it fires the Function every time a record is read by the query which makes the query to run long time.
Is there anyway I can use a subquery that fires the function only once and use the value of the function in the main query in Discoverer.
I did tried to create a custom folder for the Date functions and use it in the query so that the query references the field on the cusom folder. But still I do not see any improvement in the performance.
Thanks in advance
JayHi Jay
Yes, calculating like this on every row will have a drag on performance.
Have you considered using one of the analytic functions LAG or LEAD? They are designed for this type of reporting.
If you have considered them and rejected them can you explain why.
Another possibility is to use a SUM analytic like this:
SUM(Selling Price SUM)
OVER(PARTITION BY Size,Product
ORDER BY TO_DATE("Year",'YYYY')
RANGE BETWEEN INTERVAL '1' YEAR PRECEDING
AND INTERVAL '1' YEAR PRECEDING )
The caveat here is that RANGE INTERVAL must be a YEAR and the ORDER BY must return a date!
Does this help?
Best wishes
Michael -
Ago and To Date Functions together
Hi here is my requirement, i wanted to create a column which captures previous year's Period to date.
Period To Date gives value from 1st of this Period to today's date for present year 2012, but i want to capture the values from starting date of Period to today's date but for previous year 2011.
If for example : Period 1 of 2012, prior period would be Period 1 of 2011
I am assuming this logic will work,
First i will capture Period To Date by using (To date function), and then use AGO function where Time Offset = Period and Number of Periods = 12.
Please find the below function i used.
Ago( ToDate("Core"."Fact - Sales - Invoice Line"."Net Invoiced Amount" , "Core"."Date"."Enterprise Period" ), "Core"."Date"."Enterprise Period" , 12) .
But i found few inconsistency in the data, so kindly please help me in this.Try this.
Instead of using 2 time series functions in one columns create separate columns
ex:
1. Create Prior YTD as :ToDate("Core"."Fact - Sales - Invoice Line"."Net Invoiced Amount" , "Core"."Date"."Enterprise Period" )
2. Now create Ago column as : Ago (Prior YTD, "Core"."Date"."Enterprise Period" , 12)
HTH -
Hi all,
I have requirement to increase the given date for 3 months(ie., 01-jan-2011, 01-apr-2011,etc) that should be handled in RTF Template.
can anyone help me in giving date function for increasing the date.
Regards,
Vinoth.Take a look at the following blog post: http://blogs.oracle.com/xmlpublisher/2007/04/a_date_addition.html
also check out:
Need help in adding days to a date -
How to call a Search help in a function module?
Hi Experts,
I am a novice to ABAP, I am working on search helps. My requirement is to call a search help in a function module.
Can anyone please throw some light on this.
Any inputs will be helpful.
Thanks,
Amitayes you can do that..
in side the source code ..
write the select statement according to requirement and pass the internal table to below function moduel and return field to yor help field..
call the below fm inside the function module..
'POPUP_WITH_TABLE_DISPLAY' or 'REUSE_ALV_POPUP_TO_SELECT'
see the sample code...
FUNCTION Z_MFG_PLANTS_F4 .
"*"Local Interface:
" IMPORTING
" REFERENCE(W_WERKS) TYPE WERKS OPTIONAL
" IMPORTING
" REFERENCE(W_MATNR) TYPE MANTR OPTIONAL
Alv popup display
DATA : gc_selfield TYPE slis_selfield,
gt_fieldcat_drd TYPE slis_t_fieldcat_alv WITH HEADER LINE.
p_werks = W_WERKS.
data : begin of t_marc occurs 0,
werks type werks,
matnr type matnr,
end of t_marc
select matnr werks from marc into table t_marc where werks = p_werks.
IF t_disp[] IS NOT INITIAL.
gt_fieldcat_drd-seltext_m = 'Material'.
gt_fieldcat_drd-fieldname = 'MATNR'.
APPEND gt_fieldcat_drd.
CLEAR : gt_fieldcat_drd.
gt_fieldcat_drd-seltext_m = 'WERKS'.
gt_fieldcat_drd-fieldname = ''WERKS'.
APPEND gt_fieldcat_drd.
CLEAR : gt_fieldcat_drd.
Allow the user to select the required plant
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
i_title = 'Material Selection for Plant'
i_selection = 'X'
i_screen_start_column = 5
i_screen_start_line = 5
i_screen_end_column = 70
i_screen_end_line = 20
i_tabname = 'T_MARC'
it_fieldcat = gt_fieldcat_drd[]
IMPORTING
es_selfield = gc_selfield
TABLES
t_outtab = t_MARC
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc 0.
ENDIF.
READ TABLE t_MARC INDEX gc_selfield-tabindex.
IF sy-subrc = 0.
w_matnr = t_matnr-matnr.
ENDIF.
ENDIF.
ENDFUNCTION.
rgrds,
Shweta -
Inverte - Date function in Update Rules
Hi All,
We are writing a code for converting the data into a date field using INVERTE-DATE function.
The field GDATU in the Table TCURR needs to be converted.
GDATU - Date As of Which the Exchange Rate Is Effective. This is not in proper format, hence we used the below code to converte in to a proper one.
TABLES: TCURR.
DATA: tcurr_tab TYPE TABLE OF tcurr.
data: date_normal type sy-datum.
FIELD-SYMBOLS
<tcurr_wa> TYPE tcurr.
SELECT gdatu FROM tcurr INTO corresponding fields of
TABLE tcurr_tab.
SORT tcurr_tab BY gdatu.
LOOP AT tcurr_tab ASSIGNING <tcurr_wa>.
break-point.
CONVERT INVERTED-DATE <tcurr_wa>-gdatu
INTO DATE date_normal. "move that to normal date field
write:/ date_normal. "take a normal date field
ENDLOOP.
when I check for this code... it gives us the below error message
E:Variants with INVERTED-DATE are no longer supported in the OO context.
Use TRANSLATE ... USING '1928374664738291' instead
Can anyone suggest me what could be done to solve this issue.
Thanks,
MaddyHi Maddy,
If you do F1 help for 'Inverted-Date' you will get the reason as:
Cannot Convert Dates
The statements CONVERT DATE and CONVERT INVERTED DATE are not allowed.
An error message occurs in ABAP Objects if the following syntax is used:
CONVERT DATE f1 INTO INVERTED-DATE f2.
CONVERT INVERTED-DATE f2 INTO DATE f1.
Correct syntax:
CONSTANTS comp_nine(20) TYPE c VALUE '09182736455463728190'.
f2 = f1.
TRANSLATE f2 USING comp_nine.
f1 = f2.
TRANSLATE f1 USING comp_nine.
Reason:
Date conversions are used mainly to influence the sort sequence in in internal tables. This function can be replaced by the additions ASCENDING or DESCENDING of the statement SORT. If required, you can easily program the nines complement yourself using TRANSLATE.
Regards,
Saba
Maybe you are looking for
-
IDVD quits unexpectedly every-time I try to open it
iDVD quits unexpectedly every-time I try to open it. Is there any way of fixing this? I tried reinstalling the program with the Discs that came with my computer (that hold the operating system and some programs).
-
How can I get my notification ringtones back when I synced my iphone to icloud. Idk what I did but when I back up everything these along with some songs got erased.
-
Has anyone downloaded an album from iTunes Store, once downloaded, will let you play some songs, but others is asking you to authorize your computer. When I go through those steps, it tells me that the computer is already authorized, but still will n
-
Hello, I get the following message when trying to run cimom. I seem to be the only one in our group with this problem. Any ideas welcomed. thanks. /home/me/jdk1.5.0_05/bin/java -classpath /home/me/ProviderTools/3rd_party/wbemservices/cimom/lib/wbem s
-
Hi expert, i have to diaply project field in cat2 i can see the network but not able to display project against that n/w.anyone have idea in which function of cat2 tranasction its fetch value from project table and assign to catsdb field..or any othe