Select statement for last day of the last quarter and first quarter
Anybody provide me the single select statement which should result the last day of the last quarter and last day of current quarter?
Ex: Select last date of the last quarter,last day of current quarter from XYZ(DUAL...)
Thanks in Advance
Hi,
Here's one way:
SELECT TRUNC (SYSDATE, 'Q') - 1 AS prev_qtr_end
, ADD_MONTHS ( TRUNC (SYSDATE, 'Q') - 1
, 3
) AS this_qtr_end
FROM dual;TRUNC (dt, 'Q') returns the first day of the quarter containing dt.
Subtract one day from that, and you have the last day of the previous quarter.
Add 3 months to that, and you have the last day of the current quarter. ADD_MONTHS (dt, n) will always return the last day of a month if its first argument, dt, is the last day of a month.
Similar Messages
-
Update statement for modifying day of the month
Hi,
i hope there is an easy answer to a question i'm probably over thinking. i have a situation where i need to update all the days in a date field to a certain day of the month regardless of the month or year. Here is an example of a small number of dates in the table:
07/28/2004
04/21/2008
12/21/2011
08/21/2006
04/04/2008
04/16/2012
08/13/2011
03/01/2006
04/17/2012
So, for each of these dates the day (or DD) would need to be converted to the 15th (ie. 07/15/2004, 04/15/2008, 12/15/2011, etc). I've used to_char to pull out just the DD, but am unsure what the update statement would need to look like. Any assistance would be greatly appreciated. Thank you!If you don't care about the time component
UPDATE your_table
SET your_column = trunc(your_column,'MM') + 14Justin
Edited by: Justin Cave on Apr 26, 2012 9:47 PM
Off by 1. Should be +14 not +15 -
BI Content Variable on 0Calday for first day of the fiscal year and first day of the current month
Hi Friends,
In one of my BEx queries, I need to restrict a key figure for 0Calday based on the first day of the current fiscal year. And another key figure for the first day of the current month. Instead of using Customer exit, I hope there is some SAP delivered standard variable for these filters.
Please let me know if there is anything available for this. Your answers will be highly appreciated.
Thanks & Regards,
RanjanHi Ranjan,
Please find below standard variables.
Pls check below link for more.
Standard Variables in BEX related to Time Charcteristics
Characteristic
Variable
Description
0CALDAY
0CWD
Current Workday (SAP Exit)
0CALDAY
0CYTCD
Cumulated to Current Day (SAP Exit)
0CALDAY
0DAT
Current Calendar Day (SAP Exit)
0CALDAY
0DAY_***
Cumulation of all Values to Key Date (SAP-Exit)
0CALDAY
0LYTCLD
Cumulated to Current Day of Previous Year
0CALDAY
0LYTCLD
Previous Year Cumulated to Current Day (SAP Exit)
0CALDAY
0L_DATE
Last Calendar Date
0CALDAY
0P_LY_R
Comparative Period for Last Year
0CALDAY
0P_TY_R
Period for Current Year up to Yesterday
0CALDAY
0S_KDATE
Key Date Interval for Previous Year (SAP Exit)
0CALDAY
0S_KDAY
Key Date Interval Current Year (SAP Exit)
Best,
SATYA. -
My purchased iBook is stuck in a downloading state. Any solution?
Thank you. I know you're all users and not official Apple tech support, but I also know that the results of these discussions make their way up to search engines, and that Apple has to be aware that the issues discussed here happen.
As for the link to contact the iTunes support, I have already used that. I have a "ticket number" in their system, and have signed up for Apple to call me tonight after work. I was on hold with them yesterday for about 40 minutes, but had to hang up when my children's doctor called (they are both sick).
I was just venting, in the hopes that my venting would find others in the same troubled spot and we could share our frustratons together.
Thanks for trying to help and for listening. -
SQL select Statement -first day and last day of the month - 1 year from now
Hi,
I need to write a SQL to get the dates in between first day and last day of the month one year from now.
SELECT last_day(add_months(sysdate,12)) as lastday from dual
What could be the Query to get the first day of the month one year from now..
ie ..Sysdate - 3-DEC-2009
Result - 1-DEC-2010
thank youHi,
You can use TRUNC with 2 arguments to get the first DATE in a month, year, quarter, week, hour, minute, ISO year, ...
SELECT TRUNC ( ADD_MONTHS ( SYSDATE
, 12
, 'MONTH'
) AS first_of_month
FROM dual
;The DATE returned will be in the same month, year, quearter, ... as the first argument.
\We convered the last day of the month in [your previous question|http://forums.oracle.com/forums/message.jspa?messageID=3942939#3942939].
At that time, I warded about using LAST_DAY as a cutoff point; TRUNC is a much better way.
For example, to find all appointment_dates in the current month next year:
SELECT *
FROM appointments
WHERE appointment_date >= TRUNC (ADD_MONTHS (SYSDATE, 12), 'MONTH')
AND appointment_date < TRUNC (ADD_MONTHS (SYSDATE, 13), 'MONTH')Note that
the first part of the WHERE clause calls for dates on or equal to the beginning of the 12th month in the future, but
the second part of the WHERE clause calls for dates before, not equal to , the beginning of the 13th month in the future. -
today is last day of my lightroom trial and i dont want to lose book i am working on so i bought the photoshop/lightroom monthly package for 9.99. Where do i find the serial number to register lightroom?
There is no serial number for the CC version of LR.
You should uninstall the trial which is asking for a serial number – your catalog and images won’t be affected.
Then Quit the CC Desktop application, using Gear / Quit or right-click / Quit
Then restart the CC Desktop application.
Now you should have LR listed in the CC Desktop apps list with an Install button. -
How to get the last day of the week?
Hii
i can get the calender week number for any given date using
SELECT to_char(to_date('04/04/2011','MM/DD/YYYY'),'WW') FROM dual
can any body tell me, how to get the last day of that week ?
and the answer should be 04/08/2011(8th april )
thanks
San
Edited by: sandeep9 on Apr 4, 2011 3:50 AMHi, San,
Here's one way:
WITH sample_data AS
SELECT DATE '2011-04-04' AS dt
FROM dual
SELECT dt
, TO_CHAR (dt, 'WW') AS week_num
, NEXT_DAY ( dt - 1
, TO_CHAR ( TRUNC (dt, 'YEAR') - 1
, 'Day'
) AS end_o_week
FROM sample_data;Another way is to use date arrithmetic:
WITH sample_data AS
SELECT DATE '2011-04-09' AS dt
FROM dual
SELECT dt
, TO_CHAR (dt, 'WW') AS week_num
, TRUNC (dt, 'YEAR')
+ (7 * CEIL ( (dt - (TRUNC (dt, 'YEAR') - 1))
/ 7
- 1 AS using_date_arithmetic
FROM sample_data; -
Need to find the last day of the previous month
hi folks,
the code goes like this...
data: xt247 type t247,
monthn(30) type c,
monthnumber type i,
bforwardmonth type i.
call function 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
day_in = s_date
IMPORTING
last_day_of_month = e_date.
write: 'The last day of the month', e_date.
select single * from t247 into xt247
where spras = sy-langu
and mnr = e_date+4(2).
monthnumber = xt247-mnr.
write:' The month number', monthnumber.
determine the previous month.
bforwardmonth = monthnumber - 1.
From here I need to determine the last day of the previous month How can I do?
Thanks for your help.
SanthoshHi all,
here's the shortest solution:
REPORT z123.
PARAMETERS p_datum LIKE sy-datum DEFAULT sy-datum.
DATA ultimo LIKE sy-datum.
<b>ultimo = p_datum - p_datum+6(2).</b>
WRITE: / p_datum, 20 ultimo COLOR 2.
it's not my solution :
it's from <a href="http://www.abapforum.com/forum/viewtopic.php?t=1434&highlight=ultimo">Andrew_</a>
regards Andreas -
The last day of the month when the report is run
Hi,
I am working on custom outbound idocs for FICO module through INTERFACE Program the third party sytem needs <b> "The last day of the month when the report is run"</b> so is there any sytem field or standard SAP Sytem Table field which can give me that value.plz let me know ASAP.
Other wise should i develop custom logic.Hi,
Try this way.
Selection-screen
PARAMETERS: p_bldat LIKE bsis-bldat .
INITIALIZATION.
DATA: v_end_date LIKE sy-datum.
CALL FUNCTION 'LAST_DAY_OF_MONTHS'
EXPORTING
day_in = sy-datum
IMPORTING
last_day_of_month = v_end_date
EXCEPTIONS
day_in_no_date = 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.
p_bldat = v_end_date.
Thanks,
Anitha -
Last day from the list of dates
i have a query which give me list of dates. From these list of date i want to find the last day in all months. when i am using last day fucntion i am getting last day from the sysdate and not from the list of dates generated by my query.
the query
(select distinct to_date(substr(batch_id,1,6),'DDMMRR') batch_id from gcon_mst_v0)
order by batch_id desc
i want last day from each month from the list of dates listed from the query.
Help would be higly appriciated
Thanks in advanceThe column is a varchar but i am convering it to get
the list od dates as you can see in the query. i want
all the last dates of every month from that list of
dates for eg. below is the list of the dates i am
getting from the query.
7/11/2007
7/10/2007
7/9/2007
7/8/2007
7/6/2007
7/5/2007
7/4/2007
7/3/2007
7/2/2007
7/1/2007
6/29/2007
6/28/2007
6/27/2007
6/26/2007
6/25/2007
6/24/2007
6/22/2007
6/21/2007
6/20/2007
6/19/2007
6/18/2007
6/17/2007
6/15/2007
6/14/2007
6/13/2007
6/12/2007
6/11/2007
6/10/2007
6/8/2007
6/7/2007
6/6/2007
6/5/2007
6/4/2007
6/3/2007
6/1/2007
5/31/2007
5/30/2007
5/29/2007
5/28/2007
5/27/2007
5/25/2007
5/24/2007
5/23/2007
5/22/2007
5/21/2007
5/20/2007
5/18/2007
5/17/2007
5/16/2007
5/15/2007
5/14/2007
5/13/2007
5/11/2007
5/10/2007
5/9/2007
5/8/2007
5/7/2007
5/6/2007
5/4/2007
5/3/2007
5/2/2007
5/1/2007
4/30/2007
4/29/2007
4/27/2007
4/26/2007
4/25/2007
4/24/2007
4/23/2007
4/22/2007
4/20/2007
4/19/2007
4/18/2007
4/17/2007
4/16/2007
4/15/2007
4/14/2007
4/12/2007
4/11/2007
4/10/2007
4/9/2007
4/8/2007
4/6/2007
4/5/2007
4/4/2007
4/3/2007
4/2/2007
4/1/2007
3/30/2007
3/29/2007
3/28/2007
3/27/2007
3/26/2007
i want the last date for all the months listed. that
would be
6/29/2007 -- last day for june
5/31/2007-- last day for may
4/30/2007-- last day for april
3/30/2007-- last day for march and so on
thankswrite query as
SELECT LAST_DAY(TO_DATE(SUBSTR(COLUMN_NAME,X),'MM/DD/YYYY'))
FROM TABLE_NAME -
Generating the last day of the week
HI All,
I have the Year value (for eg 2002, 2006) and the week number value in the year ( for eg : 32, 52) . Based on this information, how can I get the last day of the particular week.
for eg What is the last day of the week - 2002,32
Any pointer would be great.
Thanks and Regards
VenkatOr try this:
SQL> WITH t AS
(SELECT 2006 YEAR, 1 week
FROM DUAL
UNION ALL
SELECT 2002 YEAR, 32 week
FROM DUAL
UNION ALL
SELECT 2005 YEAR, 52 week
FROM DUAL
UNION ALL
SELECT 2006 YEAR, 52 week
FROM DUAL)
SELECT YEAR,
week,
CASE
WHEN TO_CHAR (TRUNC (TO_DATE (YEAR, 'RR'), 'RR'), 'IW') != 1
THEN TRUNC (TRUNC (TO_DATE (YEAR, 'RR'), 'RR') + 7, 'IW')
ELSE TRUNC (TRUNC (TO_DATE (YEAR, 'RR'), 'RR'), 'IW')
END
+ 6 + (week - 1) * 7 LAST_DAY
FROM t
YEAR WEEK LAST_DAY
2006 1 08-JAN-06
2002 32 11-AUG-02
2005 52 01-JAN-06
2006 52 31-DEZ-06
4 rows selected. -
Display a metric differently only on last day of the month.
Have a Daily transaction fact where unit cost of product is stored at a day/part num /business unit level.
When we drag and drop date column and unit cost in the report like below we will have
Date cost
Sep29 $10
sep30 $12
Oct1 $12
Oct2 $14
..........ans so on
The source sustem program runs on last day of the month around 8pm for setting up cost to reflect on 1st of every month
But the nighly OBI load ( Runs at 2am every day) when incrementally updating Sep30 data picks up $12 from the erp and populates in OBI.
But actually speaking, on Sep30 the cost was $10.
There is no way of running the ERP program to run afer OBI load. Hence we need an expression in the RPD (not answers) saying
when last day of the month (any month) the standard cost must be a previous day value.All other days the same value should be returned.
Is this possible without impacting report performance ?
So, when we drag and drop date and cost value the above report should change as
Date Cost
sep29 $10
sep30 $10
Oct1 $12
Oct2 $14
Oct30 $12.5
Oct31 $12.5
Nov1 $13.5You can achieve the above requirement for current month alone with below steps:
The solution requires to have a union report
First part of the report will have Date and Cost fields with a report level date filter, Date NOT IN (TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))))
Second part of the report will have Date and Cost fields with a report level date filter Date IN (TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))))In the second part of the report,
Change the column formula for Date to display only Current_Date
Change the column formula for Cost field with FILTER(Cost USING Date = Current_Date-1)
Pls mark if correct/helpful. -
Currency Translation based on Last Day of the Acquistion month
Dear all,
Request to help me in understanding how we can calculate the currency translation rate as per the last day if the acquistion month..
For Example if the Acquistion date : 01/01/2008 (mm/dd/yyyy) the currency translation should happend based on the rate maintained as on 31/01/2008.
Thanks
Pavan Kumar PrakhyaFirst, you will need to convert the actual acquisition date to the end date of the Fiscal Period. This can be done by using two separate Function Modules. First, get the actual Fiscal Period by entering the date and Fiscal Year Variant into the DATE_TO_PERIOD_CONVERT Function Module. Use the Fiscal Year and Fiscal Period from this and determine the end date of the Fiscal Period by using Function Module LAST_DAY_IN_PERIOD_GET with Fiscal Year, Fiscal Period and Fiscal Year Variant as your inputs.
For the conversion, use the Function Module CONVERT_TO_LOCAL_CURRENCY. The inputs for this would be the last date of the Fiscal Period, the amount to be converted, the from currency code, the to currency code, blank in rate, AS01 in type of rate and X in read TCURR. This assumes, however, that month-end rates (rate type = AS01) have been loaded into your source system and these rates have been transferred to your BW environment. -
How to get the last day of the next month?
Hi all.
I need to get the last day of the next month. E.g. if the date is 20.03.2008 I need to get 30.04.2008.
Is there any FM for it?
TIA, Nikolai.hi Nikolai,
pls. have a look athe following piece of code:
PARAMETERS : p_date TYPE sy-datum.
DATA : gv_res TYPE sy-datum.
CALL FUNCTION 'CALCULATE_DATE'
EXPORTING
* DAYS = '0'
months = '2'
start_date = p_date
IMPORTING
result_date = gv_res.
==> Now you have (gv_res) 2 months later as today
gv_res+6(2) = '01'. ==> gv_res is first day of next-next month
gv_res = gv_res - 1. ==> gv_res is last day of next month
hope this helps
ec -
How to get the last day of the payroll period
Hi all,
I need to get the last day of the payroll period e.g. last day of Jan 2007 is 31 Jan 2007. Can anyone suggest as to how to get it?
Thanks,
MadhuT549S contains the payroll periods with pay date. T549Q contains the begin and end dates of the payroll period.
You can select from the appropriate table (or from both depending on your given data) to get the end date of the period.
Hope that helps.
Mary
Maybe you are looking for
-
Best practice for modelling rediects using the threat modelling tool
I'm in the process of modelling systems using the threat modelling tool. There services in question do a lot of redirecting and handing off to one another on the client side, including things like ACS and identify providers. If Web App A redirects to
-
Sun ONE Portal Server 6.1 - Reporting features
Hi, I am just curious whether the Portal Server has any built-in feature for adhoc reporting (based on the user selection). If yes please suggest me on how to enable the same / use the same. Thank you, V
-
Phone locked up after not ejecting after updating in itunes
My IPhone 4 was disconected from Itunes while it was updating. As a result the phone locked up. Tried restarting and resetting - that did not work either.When trying to start it it doesnt go past the screen with the Itunes picture telling to plug it
-
Solved the Illustrator CS3 Crash Error upon saving file on my OS.
I was unable to save any Illustrator file. Upon saving a file Illustrator CS3 crashed and an error message would pop up and windows error reporting service would be launched to report the error and close Illustrator.exe. Until i found out that i had
-
ITunes won't launch after latest update
Hi. I've just downloaded and installed (through system update) the latest iTunes version and now it won't launch. It worked perfectly fine fine before the update but now it won't open. Icon bounces then just stops... Any ideas!? Thank you!