How to get Week,Month and Year details from a date column
Hi frenz,
I've a column like tran_date which is a date column..... I need the next week details based on this column and so on...
I need month and year details as well based on this tran_date column.... can any one tell me how...
Thanks in advance
My example for objects:
create or replace type date_object as object
centure number,
year number,
month number,
day number,
hour number,
minute number,
second number,
daypart number,
week number,
constructor function date_object(p_dt date)
return SELF as result
create or replace type body date_object is
constructor function date_object(p_dt date)
return SELF as result
as
begin
SELF.centure:= trunc(to_char(p_dt,'YYYY')/100);
SELF.year:= to_char(p_dt,'YYYY');
SELF.month:= to_char(p_dt,'MM');
SELF.day:= to_char(p_dt,'DD');
SELF.hour:= to_char(p_dt,'HH24');
SELF.minute:= to_char(p_dt,'MI');
SELF.second:= to_char(p_dt,'SS');
SELF.daypart:= p_dt-trunc(p_dt,'DD');
SELF.week:= to_char(p_dt,'IW');
return;
end;
end;
select date_object(sysdate),
date_object(sysdate).year
from dual;Regards,
Sayan M.
Similar Messages
-
Find month and year of a given date
Hi,
How to find the month and year of a given date.
month ( sy-datum) year ( sy-datum )
--Balahi
DATA: EDAYS LIKE VTBBEWE-ATAGE,
EMONTHS LIKE VTBBEWE-ATAGE,
EYEARS LIKE VTBBEWE-ATAGE.
PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
Call Function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
exporting
i_date_from = FROMDATE
i_date_to = TODATE
I_FLG_SEPARATE = ' '
IMPORTING
E_DAYS = EDAYS
E_MONTHS = EMONTHS
E_YEARS = EYEARS.
WRITE:/ 'Difference in Days ', EDAYS.
WRITE:/ 'Difference in Months ', EMONTHS.
WRITE:/ 'Difference in Years ', EYEARS.
INITIALIZATION.
FROMDATE = SY-DATUM - 60.
Using teh abiove u can get difference but when u pass previous year u wont get the exact.
There is no seperate FM for this, u have to use three FM.
If possible using these three FM code u can create an FM.
For years and months between two days:
DATA: EYEARS LIKE VTBBEWE-ATAGE.
PARAMETERS: FROMDATE LIKE PREL-BEGDA,
TODATE LIKE PREL-BEGDA DEFAULT SY-DATUM.
CALL FUNCTION 'COMPUTE_YEARS_BETWEEN_DATES'
EXPORTING
first_date = fromdate
MODIFY_INTERVAL = ' '
second_date = todate
IMPORTING
YEARS_BETWEEN_DATES = EYEARS
EXCEPTIONS
SEQUENCE_OF_DATES_NOT_VALID = 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.
Write:/ eyears.
DATA: EMONTHS LIKE VTBBEWE-ATAGE.
PARAMETERS: FROMDATE LIKE SY-DATUM,
TODATE LIKE SY-DATUM
DEFAULT SY-DATUM.
CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = fromdate
i_datum_von = todate
I_KZ_INCL_BIS = ' '
IMPORTING
E_MONATE = emonths
write:/ emonths
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
I_DATUM_BIS = x_faede-zfbdt
I_DATUM_VON = p_fdat
I_KZ_EXCL_VON = '0'
I_KZ_INCL_BIS = '0'
I_KZ_ULT_BIS = ' '
I_KZ_ULT_VON = ' '
I_STGMETH = '0'
I_SZBMETH = '1'
IMPORTING
E_TAGE = dias_v.
IF SY-SUBRC <> 0.
ENDIF.
x_faede-zfbdt -> 20050915
p_fdat -> 20050811
dias_v = 4
try this and let me know.
regards
ravish
<b>plz dont forget to reward useful points</b> -
How to get current month and last month dynamically??
how to get current month and last month dynamically
like
month = getCurrentMonth();
lastmonth = getcurrentMonth() -1;
please help
thankshi :-)
/* depracated but can be still useful */
java.util.Date dtCurrent = new java.util.Date();
int month = dtCurrent.getMonth();
int lastmonth = dtCurrent.getMonth() - 1;
System.out.println("* " + month);
System.out.println("* " + lastmonth);
/* better to use this one */
Calendar cal = new GregorianCalendar();
int imonth = cal.get(Calendar.MONTH);
int ilastmonth = cal.get(Calendar.MONTH) - 1;
System.out.println("*** " + imonth);
System.out.println("*** " + ilastmonth);
regards, -
Getting Day, month and year from Date object
hello everybody,
Date mydate = Resultset.getDate(indexField);
Now i would like to get day, month and year from mydate.
In another words, i'm looking for something equivalent to
mydate.getDay() as this method is deprecated.
Can somebody help me out please?
Thank you in advance,swvc2000,
Here is a sample class that demonstrates two ways in which to do this.import java.util.*;
import java.text.*;
public class DateSplitter {
public static void main(String args[]) {
/* even though your date is from a result set,
pretend the following date is your date that
you are using. The try catch block is used
because I hand-crafted my date using
SimpleDateFormat. Substitute your date.*/
Date yourDate = null;
try {
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
yourDate = formatter.parse("05/06/2000");
} catch (ParseException e) { }
//the following gets the current date
Calendar c = Calendar.getInstance();
//use the calendar object to set it to your date
c.setTime(yourDate);
//note months start at zero
int month = c.get(Calendar.MONTH);
int year = c.get(Calendar.YEAR);
int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
System.out.println("Calendar Month: "+month);
System.out.println("Calendar Day: "+dayOfMonth);
System.out.println("Calendar Year: "+year);
System.out.println();
/* Simple date format can also be used to strip them
out of your date object. When you use it, notice that
months start at 1. Also, it returns string values. If
you need integer values, you will have to use
Integer.parseInt() as I did below. If you are
only concerned about the string values, just remove
the Integer.parseInt part. */
DateFormat formatter = new SimpleDateFormat("M");
month = Integer.parseInt(formatter.format(yourDate));
System.out.println("SDF Month: "+ month);
formatter = new SimpleDateFormat("d");
dayOfMonth = Integer.parseInt(formatter.format(yourDate));
System.out.println("SDF Day: "+ dayOfMonth);
formatter = new SimpleDateFormat("yyyy");
year = Integer.parseInt(formatter.format(yourDate));
System.out.println("SDF Year: "+ year);
}//end main
}//end DateSplitter classtajenkins -
How to have more months and years appear for selection in the archives for blog posts?
Hello,
How to have more months and years appear for selection in the archives for blog posts? It just shows past 3 months in the year 2014, but we have many blog posts in years 2013, 2012 and 2011 and further back. I am using the OOB SharePoint blog
feature.
PaulHi,
Thanks for the reply; it doesn't add anything as RSA6 was one of the options I listed and this was my fall back option if there was no other special treatment for the COPA datasources.
I have found out why this, and other fields, are not available in KEB0. The program uses a Function called KERA_COPA_METADATA_INTERFACE within which there is a section that selects the COPA fields:
***** 1. RULES (choice/class)
* set rules for fixed fields
PERFORM COPA_SET_RULES_FIXED_FIELDS USING I_ACCTCOST
CHANGING E_T_RULES[].
When you look at this code section there is a hard coded list of fields to exclude:
MRULE 'MANDT ' NEVER FORGET_IT NEVER FORGET_IT.
MRULE 'PAOBJNR ' NEVER FORGET_IT NEVER FORGET_IT.
MRULE 'PASUBNR ' NEVER FORGET_IT NEVER FORGET_IT.
MRULE 'PAPAOBJNR ' NEVER FORGET_IT NEVER FORGET_IT.
MRULE 'PAPASUBNR ' NEVER FORGET_IT NEVER FORGET_IT.
MRULE 'HRKFT ' NEVER FORGET_IT NEVER FORGET_IT.
MRULE 'HZDAT ' NEVER FORGET_IT NEVER FORGET_IT.
MRULE 'USNAM ' NEVER FORGET_IT NEVER FORGET_IT.
MRULE 'RKESTATU ' NEVER FORGET_IT NEVER FORGET_IT.
MRULE 'TIMESTMP ' NEVER FORGET_IT NEVER FORGET_IT.
MRULE 'PERDE ' NEVER FORGET_IT NEVER FORGET_IT.
MRULE 'PERIO ' OBLIGATORY CHAR_CE3 OBLIGATORY CHAR_CE3.
MRULE 'COPA_AWTYP' NEVER FORGET_IT NEVER FORGET_IT.
MRULE 'COPA_AWORG' NEVER FORGET_IT NEVER FORGET_IT.
As this is a standard delivered SAP function I do not recommend that you change this code as you will invalid your SAP support and upgrade paths.
Thanks
Neil -
Can we modify the pnp selection screen and get only month and year?
Dear Freinds,
I have requirement where i have to modify the PNP selection screen. So with the help of report category and coding in AT SELECTION-SCREEN OUTPUT , i have modified all the fields relating to dates . i.e i have removed all the radio buttons (i.e Today, Current month,current year etc) and finally
i have landed with only Period ( PNPBEGDA & PNPENDDA range) . But i dont want the PNPBEGDA & PNPENDDA range , but i want only is the month and year ( i.e just like the PNPPABRP & PNPPABRJ)
on my selection screen along with the pernr .
i have used the below code to close all the fields except pnpbegda and pnpendda.
AT Selection-Screen output.
loop at screen.
IF screen-group4 = '098' .
screen-input = '0'.
screen-invisible = '1'.
ENDIF.
IF screen-group4 = '092' .
screen-input = '0'.
screen-invisible = '1'.
ENDIF.
IF screen-group4 = '094' .
screen-input = '0'.
screen-invisible = '1'.
ENDIF.
IF screen-group4 = '100' .
screen-input = '0'.
screen-invisible = '1'.
ENDIF.
IF screen-group4 = '104' .
screen-input = '0'.
screen-invisible = '1'.
ENDIF.
MODIFY SCREEN.
endloop.
i.e on my selection screen i want only month & year combination and pernr -
when iam using the logical database PNP . Could any one please let me know how can i get only mon & year only on my selection screen .
If it is possible please let me know .
Thanks & regards
divya.Hi ,
The requirement is that the user doesnt want to enter the date range i.e for ex: 01012008 to 31012008.
As per the requirement the user will enter only the month and year only . so i on the selection screen
i want only the month and year only . Is there any means i can modify the date period which is there by
default (PNPbegda and PNPendda) on PNP selection screen. Instead of we givign to the user the
PNPBEGDA and PNPPENDA i want is only month and year .
AS already the code has already been written and now they have asked that they want only the month and year on the selection screen.
Please suggest me in this regard.If iam hiding all the buttons relating the dates fields, and now if iam adding the parameters for the month and year it is coming below below the fields pernr , personnel ara and subara , company code , payroll area, employee group of the standard fields of PNP selection screen , there by any body could please suggest me how to change.
regards
divya. -
Get day month and year of a date
Hi all i need to get the week day of a date, the week, the month, the year of a generic date.
Actually SimpleDateFormat is probably better. Calendar's months are opaque constants.
http://www.javaalmanac.com/egs/java.text/FormatDate.html -
Problem to insert only month and year instead of full date
select b.penjara_id, p.penj_lokasi, a.no_daftar, b.episod, b.nama1,to_char(a.trkh_mula_prl,'dd/mm/yyyy') as trkh_mula_prl, to_char(bulan_proses,'mm/yyyy') as bulan_proses,
b.epd, b.lpd
from prl_daftar_proses a, senarai_pesalah b, penjara p
where a.no_daftar=b.no_daftar
and a.episod=b.episod
and b.penjara_id = p.penjara_id
and a.setuju_jplp is null
and a.bulan_proses between to_date(:FROM,'dd/mm/yyyy') and to_date(:TO,'dd/mm/yyyy')
order by b.penjara_id, a.bulan_proses,a.no_daftarHi,anyone can help me how i can insert only month and year from the value that have full date in the database??
for example,the date is 09/18/2012, but i just want to insert 09/2012 as parameter. If i want to insert only one parameter, i can do that..But i have problem when I want to insert two parameters..jeneesh wrote:
Welcome to the forum..
This..?
Assuming bulan_proses is a date without time part
select b.penjara_id, p.penj_lokasi, a.no_daftar, b.episod, b.nama1,to_char(a.trkh_mula_prl,'dd/mm/yyyy') as trkh_mula_prl, to_char(bulan_proses,'mm/yyyy') as bulan_proses,
b.epd, b.lpd
from prl_daftar_proses a, senarai_pesalah b, penjara p
where a.no_daftar=b.no_daftar
and a.episod=b.episod
and b.penjara_id = p.penjara_id
and a.setuju_jplp is null
and a.bulan_proses between to_date(:FROM,'mm/yyyy') and last_day(to_date(:TO,'mm/yyyy'))
order by b.penjara_id, a.bulan_proses,a.no_daftar
i got another problem..
before that.may i know what is the function of last_day? -
To get line item and confirmation details from CRM_ORDER_READ
Hi,
Please can anybody let me know which the field from which i can get line item details and material for the service order given?
I am using CRM_ORDER_READ to retrieve the values. In that i am exporting 4 fields - et_orderadm_h, et_orderadm_i, et_product_i, et_doc_flow. So from where to get line items and material id from these fields?
I will be very thankful if i get the answer of this question.Hi,
The attribute NUMBER_INT of ET_ORDERADM_I contains the Item Number.
Hope this helps!
Regards,
Rohit -
How to get Storage unit and Warehouse number from Handling Unit.
hello all,
I have Handling unit and Material in my program as an input, using these two fields i have to get corresponding storage unit and ware house number, to pick up transfer order.
Can anybody explain me who can we get Storage Unit and Warehouse Number from Handling Unit.
I know we can pull transfer order from table LTAK & LTAP using warehouse number.
But i dont understand how to get warehouse number from handling unit.
There is table LSUTO which has warehouse and Handling unit relation, but in our system there is not data maintained in that table. So, i was just wondering how can i get warehouse number from the given handling unit number.
please guide me
thanks
Edited by: Mr A on May 12, 2008 1:23 AMHi ,
Check out the handling unit item table VEPO. You got storage location(LGORT) in it.
Reward points if it was useful.
Regards,
Abhishek -
How to get week number and day in my result?
hi experts, i have given the data is ID and DATE(yyyymmdd),i want to get output like ID,DATE,WEEKNO,YEAR,MONTH,DAY. how to get this output.
thanks & regards
vijayIn a routine transformation you can call function
DATE_GET_WEEK
to get the week number from the date.
To determ the others, use the substring
YEAR = DATE(4)
MONTH = DATE+4(2)
DAY = DATE+6(2) -
How to get ONLY month and MONTH within date...
I have to convert something from sql server to oracle.
In SQL Server I have:
SELECT
TEXT_26 AS CostUnit,
MILESTONE_DATE AS ContractShipDate,
ACTUALFINISH AS ActualShipDate FROM PROJ_TASK
WHERE
TEXT_29='SHIP'
AND NAME NOT LIKE 'CMSB%'
AND NAME NOT LIKE 'CCFB%'
AND (MONTH(ACTUALFINISH) = MONTH(GETDATE()) - 1)All seems very simple SQL except I don't know how to convert that last line:
... AND (MONTH(ACTUALFINISH) = MONTH(GETDATE()) - 1)Basically Im just extracting the month so that I say the MONTH of the actual finish date is equal to the month of Today - 1. Meaning get the month for today (GETDATE() in sql server) and then subtract ONE month from it.
How can I do that line in oracle?
Thanks,
JonI generally find it simplier if one answers the question I posedYou need to realize that with free advice and help you get what you pay for. If you want people to run the statements for you then you should provide create table and sample data scripts.
Another alternative is
trunc(actualfinish,'mm') = add_months(trunc(sysdate,'mm'),-1)http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/functions201.htm#i79761
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/functions004.htm#i76717 -
How to get week of a year in American Standard
Hi,
I know it might be a repetitive question, but did not find a convincing solution to it in any of the previous threads. I am looking for a function (user defined, if someone has already written it) to return me the week of the year, in American Standard. i.e,the week should start on Sunday and end on Saturday (and NOT from Monday to Sunday)
01/03/2010 - Should be the start of 1st week of 2010...... 01/10/2010 will be the start of second week and so on
01/04/2009 - Should be the start of 1st week of 2009...... 01/11/2009 will be the start of second week and so on.
Does any one have a function that takes a date as input and returns back the week of the year in this above format? Any help is greatly appreciated.
ThanksIt's a bit trickier because the ISO rule has some fine prints.
Take a look at the example below:
SQL> with t as (
2 select to_date('01/02/2010', 'MM/DD/YYYY') dt from dual union all
3 select to_date('01/03/2010', 'MM/DD/YYYY') dt from dual union all
4 select to_date('01/03/2009', 'MM/DD/YYYY') dt from dual union all
5 select to_date('01/04/2009', 'MM/DD/YYYY') from dual)
6 --
7 select dt,
8 to_char(dt+1, 'iw') tweaked_week,
9 to_char(dt, 'ww') nls_week
10 from t
11 order by dt;
DT TWEAKED_WEEK NLS_WEEK
3/1/2009 01 01
4/1/2009 02 01
2/1/2010 53 01
3/1/2010 01 01
SQL> If may notice that 02/01/2010 is week 53 and and that at the same time 03/01/2009 is already week 1, being 04/01/2009 week 2.
The reason is in the docs:
An ISO week always starts on a Monday and ends on a Sunday.
* If January 1 falls on a Friday, Saturday, or Sunday, then the ISO week that includes January 1 is the last week of the previous year, because most of the days in the week belong to the previous year.
* If January 1 falls on a Monday, Tuesday, Wednesday, or Thursday, then the ISO week is the first week of the new year, because most of the days in the week belong to the new year.It depends on what your requirement asks.
If you need to prevent any January 1st that fall on Monday to Thursday from becoming your week 1 you'd probably have to adjust that implementation and fine tune it further.
Let us know if that will do or what your rule would be otherwise. -
How to get Current Quarter and Fiscal Quarter for a Date - Fiscal Year starts from 1st April
Hi,
I need to calculate current quarter and fiscal quarter in my Sql query.
I have a column for DateTime Datatype.
I need to find out Current Quarter Name like Q12012, Q22012, Q32012, Q42012 and Fiscal Quarter Name as well.
Now Fiacal Year starts from 1st April, and Current Quarter starts from 1st Jan.
For Current Quarter of 2012
Jan-Mar = Q12012
Apr-Jun = Q22012
Jul-Sep = Q32012
Oct-Dec = Q42012
For Fiscal Quarter of 2012 ( starts from 1st Apr, 2011 )
Apr2011-Jun2011 = Q12012
Jul2011-Sep2011 = Q22012
Oct2011-Dec2011 = Q32012
Jan2011-Mar2012 = Q42012
means if its 1st April, 2012,
its a new Fiacal Year 2013 so Fiacal Quarter Name should be Q12013
and its Current Quarter Name should be Q22012
Can you help me to calculate this in a select query for given dates?
Thanks in advance,
NiravThis should do it..
Select
FORMAT(datepart(quarter,getdate()),'Q#')+FORMAT(getdate(),'yyyy') -
How to get the user and groups information from http header
Hi All,
In my current scneario, we are using Siteminder for SSO setup.. And in this process, after authentication and authorization, they are going to append the user information and group information of the user into a HTTP header and it will be sent back to our presentation services.. We have to extract the user information and group information from the http header.
My HTTP header will look like as follows..
SM_USER XYZ
SM_USERDN CN=Firstname\, Lastname\, xyz, OU=GPO-Low Level Security,OU=Domain Users,OU=BU FDT,
SM_USERGROUPS CN=GG-CA-SiteminderAdmins, OU=Global,OU=Domain Groups, DC=com^CN=GG-ServiceDeskAdmin-TCCORPCEFS
And also if anyone explain me the overall working of SSO in detail like how presentation services will make a connection to BI server( I guess using Impersonator User), and also how our BI server will read the URL from presentation services and the over all working flow in our OBIEE..
Thanks a lot....Please use the search! this topic has come up lots of times already.
Maybe you are looking for
-
Hi I want to add characteristic relationship to a BI-IP model. The help docs stats: 'We recommend that you derive your own class from the example class 'CL_RSPLS_CR_EXIT_BASE'. You then only have to implement the methods CHECK, DERIVE and CREATE
-
Mouse down? filter no funciona correctamente
Tengo una estructura de eventos, en esta está un filtro de mouse down?, tengo un string control en el panel. Cuando esta activada la propiedad key focus del string control, quiero filtrar todos los click en la vi, el problema es cuando se le da click
-
New to Enhancements and Modifications in SAP ABAP
Hi experts, Could anyone has a tutorials or ebooks on this topic? I need to learn more about this.. tnx in advance!!!
-
I am trying to deploy an ADF application to my trial instance of Java cloud, I am getting the following error: 2013-10-15 08:24:18 CDT: Deploy Application started 2013-10-15 08:24:19 CDT: weblogic.management.DeploymentException: [Deployer:149189]An a
-
An album has more than one song with the same number
For example it has many of the different tracks but they share numbers...ie 1) track A 1)Trackb 1) Track C.... I thinks its purely cosmetic but is a little annoying. All help is appreciated, thank-you very much.