1st & last day of month based on month selected
Hi All,
I am an infant in BO. I want to create a variable in which I need to compare Order Creation Date with First Day of Month and Last Day of Month.
I have gone through the posts here regarding this, I found huge no of posts on calculating the 1st & last day of month based on a date value. But,
I don't have any date objects in the universe level, instead I have only Month Name/Month Number objects in the universe level (as it is a monthly report)
So, How to create 1st day & last day of month based on the month selected.
That is, If I run the report for FEB 2011 (Prompt values), I need the outputs as 01/02/2011 & 28/02/2011 as my 1st & last date values respectively.
I am working on BOXI R 3.1
Thanks in Advance,
Mitch
Hi
Create a variables and write a formula like
Also add Month number Object in query level
Var_Month
=userresponse("Enter Month")
Var_A
"01/"MonthNumberObj+Right(var_Month;4)
var_First date
Todate(var_A;"dd/MM/yyyy")
var_lastdate
=lastdayofmonth(var_Firstdate)
Note: check the default format for date according to ur database like MM/dd/yy or something like that . and add in the var_firstdate
regards
Sunil
Similar Messages
-
Rolling Months - Month By Month based on month of variable ending date
Post Author: jeffr
CA Forum: Formula
Hi,
We want to do a rolling 3 month report, based on the ending month where the ending date is entered as a run time parameter, for example run-time parameter - {?Ending Date} entered is 15 June 2007
First month - should have all of June 2007
Previous month shoud have all of May 2007
Earlier month should have all of April 2007
We tried Month() = Month({?Ending Date}) for current month and
Month () = Month (DateAdd("m",-1,({?Ending Date}))), and
Month () = Month (DateAdd("m",-2,({?Ending Date})))
but they didnt work successfully
Could someone please let us know the best way to do it with Crystal X?
ThanksPost Author: Charliy
CA Forum: Formula
You need to get six dates set up as formulas
BOM3 = date(year({?parameter}),month(),1) First day of Month3 = June 1
EOM3 - do a dateadd of one month to your parameter, then follow above example to make it the first day of next month and subtract one day
BOM2 first day of EOM2
EOM2=- BOM3-1
BOM1 first day of EOM1
EOM! = BOM2 -1 -
To retrive previous month based on month prompt
Hi,
My universe is based on SAP BEX query. I have a requirement to report the previous month data based on a month prompt. Since the universe is based on the MDX, could anyone suggest a way to calculate previous month from universe.
Appreciate your responses.
Regards,
VyshBOpvinesh wrote:
Hi VyshBO,
>
> You can refer below syntax and prepare a filter object in universe to get Previous Month.
>
>
<FILTER KEY="[ZMONTH].[LEVEL01].[[ZMONTH]].[Value]"><CONDITION OPERATORCONDITION="Equal"><CONSTANT CAPTION="-1"/></CONDITION></FILTER>
>
>
> Regards,
> Vinesh
Can you explain that syntax, Vinesh? In particular, what does the [[ZMONTH]] imply? -
Getting last days of several months - Bex Analyzer
Hello, BW experts~
I need to calculate with last days of several months.
For example,
- The sales in July: $100
-> sales per day in July = $100 / <b>31</b>
- The sales in last month(June): $100
-> sales per day in last month(June) = $100 / <b>30</b>
- The sales in 2 month ago(May): $100
-> sales per day in 2 month ago = $100 / <b>31</b>
I used to calculate a last day on a month with a customer exit variable. It works well when executing the BEx query with one month. But, when executing the query with 3 months, it doesn't work well.
For example, when executing the query in July, all last days, which are calculated via customer exit variable, become 31. Only one month.
- Last day -
July: <b>31</b>
Last month(June): <b>31</b>
2 month ago(May): <b>31</b>
They have to be each 31(July), 30(June), 31(May).
I want to get fit last days of several months at a time and one BEx query.
Is it possible? (I wish it's possible.)
Can I do something in CMOD?
Thank you~
Sihyoung JurnHi,
You can get it by creating 3 formula variables with 'customer ext' as processing.
Let us assume user enters the First month by a 'user entry' variable.
In the code of user exit for 1st formula variable you will calculate the last day of the user entered month.
In the code of user exit for 2nd formula variable you will calculate the last day of the (prevoius month to user entered month).
Similarly for 3rd Formula Variable also.
there will be 3 Restricted key figures.
one for sales of user entered month.
2nd one for sales of prevoius month to user entered month.
3nd one for sales of two month to user entered month.
you will have 3 calculated kfs.
in first one you do 1st RKF/Formula variable1.
in second one you do 2nd RKF/Formula variable2.
in third one you do 3rd RKF/Formula variable3.
Hope, you understood my explanation.
With rgds,
Anil Kuamr Sharma .P -
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> -
Get first and last day given month name with combobox
hi guys ;
I loaded to month name in combobox and I want to get first and last day by the name of month from selected Combobox
So if I select to february than results get 01.02.2015 and 28.02.2015
if select March than 01.03.2015 and 31.03.2015
Thanks .Thank you for useful post , How to change Culturinfo as a Turkish Month name ?
your's code is work if I use English month name But it was get error when use the turkish month name
If you are running your application on a Turkish Windows you could use the System.Globalization.CultureInfo.CurrentCulture:
int month = DateTime.ParseExact(monthName, "MMMM", System.Globalization.CultureInfo.CurrentCulture).Month;
Or you could use create an explicit culture object like this:
System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("tr-TR");
int month = DateTime.ParseExact(monthName, "MMMM", ci).Month;
Please remember to mark all helpful posts as answer to close your threads. -
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 AdvanceHi,
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. -
Last day of each month in a year based on a Input date?
Hi all,
I have a request from a customer who wants to have a yearly report created in BEx Query Designer which starts in January up to December and they want to have a Month To Date (MDT) and Year to Date (YTD) calculation of a key figure. This report will only show one year at the time based on the date the user give as input at the Variable Screen.
This key figure should be calculated by using the last date of each month for input when performing the MTD and YTD calculation and summarizations.
Example:
January: 31.01.2008 Key Figure = 1000. MTD = 1000 and YTD = 1000
February: 29.02.2008 Key Figure = 2500. MTD = (2500-1000) 1500 and YTD = 2500
March: 31.03.2008 Key Figure = 6000. MTD =(6000-2500)=3500 and YTD = 6000
Etcu2026.
This means that I have to have a lot of hidden Key figures which gets restricted on the different month end dates and formulas to calculate the different MTD and YTD results for the months as the year progresses.
The way I have solved it now is that I have a Customer Exit which gives me the Last day of last year (Exp: 31.12.2007) based on input date and use a Offset on the last day of last year date to get the different last dates of each month.
Since we have a leap year (one extra day in February) this year, the offset to calculate the end month dates will be different for 2007 and next year (2009). This solution is not very flexible, and it will not give the correct MTD and YTD if the customer wants to go back to 2007 and off course next year (2009).
One solution is to create 12 Customer Exits that gives me the different month end dates (January-December), and also takes in account leap year for February for the different years. These Exits will be based on the Input date the Customers put in at the variable screen.
I would rather want to avoid making 12 new customer exits and want your advice and expertise to find out if this is possible in any other way (maybe with only 1 customer exit) to get the last date of each month based on an input date.
Thanks for all your advices on beforehand.
Regards
Oddmar LidHi,
Thanks for you replay and documentation, but it doesn't give me excatly the functionality I'm after. The only MTD calculation code the document provides is the calculation of the following functionality:
"Month to Date (MTD) u2013 From the 1st of month to u201CKey Dateu201D - for current year." This doesn't give the the functionality I want, which is to retrieve a given vaule for a Key Figure for the last dates of the months in a year to calculate MTD and YTD.
This way I have created the query is to have multiple hidden Key Figures that calculates the MTD and YTD.
In Columns in Query Designer it will look something like this:
Selection: MTD January--> Date = 31.01.2008, Key Figure (Always Show)
Selection: YTD January --> Date= 31.01.2008, Key Figure (Always Show)
Selection: MTD February --> Date= 29.02.2008, Key Figure (Always Hide)
Formula: MTD February --> MTD February - MTD January (Always Show)
Selection YTD February --> Date = 29.02.2008, Key Figure (Always Show)
And so on....
This is off course a simplified version, but it shows the core of the solution. What I want to achive here is that the dates used to get the Key Figures (last date of a month) is calculated as flexible as possible, so that the users can go back and forth in time without worrying about the leap year problem and so on. I have now used an offset from the last date of last year and this is good for all the normal years, but when it is a leap year the query will use wrong dates to get the key figure vaule for the last date of each month.
Any ideas on how to achieve this without creating 12 different Customer Exit variables (one for each end date of each month)?
Thanks
Regards
Oddmar Lid -
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 find first and last day of previous month?.
Based on current month, I want to find start and end day of
previous month.
For example,
For august, Start date is July 1st and End date July 31st.
How can i get first of previous month as start date and last
day of the previous month as end date?.
Same way,
i want to find start date of current month and end date of
next month.
Example:
For august,
i want to get start date, august 1st and end date : september
30.
How can i do this from current date or now().
I am looking for best and easy way to find start and end
dates..
Thanks<cfset today = now()>
<cfset firstOfThisMonth = createDate(year(today),
month(today), 1)>
<cfset lastOfNextMonth = dateAdd("d", -1, dateAdd("m", 2,
firstOfThisMonth))>
<cfoutput>
today = #today#<br>
firstOfThisMonth = #firstOfThisMonth#<br>
lastOfNextMonth = #lastOfNextMonth#<br>
</cfoutput>
Edit - To find the start and end day of previous month, get
the first of THIS month. Use Subtract 1 month ("m") to get the
start date. Subtract 1 day ("d") to get the end date. -
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. -
How to get the last day of the previous month
Hello Team,
If my input date is today , then i need to find out the last day of the previous month for the same.
Can someone help me to find out .. how can this be done.
Regards,
RaviHi,
Try the below code.
// get a calendar object
GregorianCalendar calendar = new GregorianCalendar();
// convert the year and month to integers
int yearInt = Integer.parseInt(year);
int monthInt = Integer.parseInt(month);
int dayInt = Integer.parseInt(day);
// adjust the month for a zero based index
monthInt = monthInt - 1;
// set the date of the calendar to the date provided
calendar.set(yearInt, monthInt, dayInt);
int day = calendar.getActualMaximum(GregorianCalendar.DAY_OF_MONTH);
return Integer.toString(day);
Regards
Venkat -
Formula to calculate the last day of the subsequent month
Hi - I am trying to create a formula in CR9 that will take a date field and translate it to the last day of the subsequent month. For example, I have a date of today, 2/3/2009. I need it to print on the report 3/31/2009. I have made some progress to get me the 1st day of the subsequent month, but I need it to be the last day of the subsequent month.
The formula I am have currently is:
DateSerial(Year({Name.JOIN_DATE}), Month({Name.JOIN_DATE}) + 1, 0)+1
this will give me 3/1/2009, but I need 3/31/2009.
Any help appreciated.
Thanks!Hi Joe,
You can use the following logic which also takes into account the extra day in a leap year. You will need 5 formulas for this:
First create a formula that calculates current month, call it @Current Month MM
Month(Name.JOIN_DATE)+1
Next create another formula called @Current Month Start Date which will give you the beginning of the month.
totext(Date (year(currentdate),tonumber({@Current Month MM}) ,1 ))
Next create another formula called @Current Year yyyy
Year(Name.JOIN_DATE)
Next, create a formula called @DaysofMonth with the following logic:
if tonumber({@Current Year yyyy}) mod 4 = 0 then
choose(month(date({@Current Month Start Date})),31,29,31,30,31,30,31,31,30,31,30,31) else
choose(month(date({@Current Month Start Date})),31,28,31,30,31,30,31,31,30,31,30,31)
Lastly create a formula called @Ending Date of Month
totext(Date (year(currentdate),tonumber({@Current Month MM}) ,{@DaysOfMonth} ))
I hope this information proves useful.
Regards,
Zack H.
Edited by: Zack H on Feb 3, 2009 5:34 PM
Edited by: Zack H on Feb 3, 2009 5:38 PM -
How to find first and last day of last month?.
Hello,
I am using Crystal Report XI.
Reports will be generated on first of every month for
previous month. I want to find start and end date of previous month
dynamic.
For august, Start date is July 1st and End date July 31st.
For September, start date is Aug 1st and Aug 31st.
How can i get first of previous month as start date and last
day of the previous month as end date?.
Same kind of thing I want to do for future report ..find next
month start date and end date.
ThanksAdomacro,
you could do a function, like this
<cffunction name="getReportdates" returntype="struct"
hint="Given an arbitrary month and year, the function returns a
structure containing the first and last day of the previous
month">
<!--- Take current month and current year as the default
--->
<cfargument name="mnth" type="string" required="No"
default="#monthAsString(month(now()))#">
<cfargument name="yr" type="numeric" required="No"
default="#year(now())#">
<cfset firstDayOfGivenMonth = parseDateTime("1 " &
arguments.mnth & " #arguments.yr#")>
<cfset lastDayOfPreviousMonth =
dateAdd("d",-1,firstDayOfGivenMonth)>
<cfset numberOfDaysOfPreviousMonth =
daysInMonth(lastDayOfPreviousMonth)>
<cfset firstDayOfPreviousMonth =
dateAdd("d",-#numberOfDaysOfPreviousMonth#,firstDayOfGivenMonth)>
<cfset reportDates = structNew()>
<cfset reportDates.firstDayOfPreviousMonth =
firstDayOfPreviousMonth>
<cfset reportDates.lastDayOfPreviousMonth =
lastDayOfPreviousMonth>
<cfreturn reportDates>
</cffunction>
<!--- Example usage --->
<p>
Given month: <strong>March
2004</strong><br>
begin date:
<cfoutput>#dateFormat(getReportdates('March',2004).firstDayOfPreviousMonth,"d
mmm yyyy")#</cfoutput><br>
end date:
<cfoutput>#dateFormat(getReportdates('March',2004).lastDayOfPreviousMonth,"d
mmm yyyy")#</cfoutput><br>
</p>
<p>
Given month: <strong>August
2007</strong><br>
begin date:
<cfoutput>#dateFormat(getReportdates('August',2007).firstDayOfPreviousMonth,"d
mmm yyyy")#</cfoutput><br>
end date:
<cfoutput>#dateFormat(getReportdates('August',2007).lastDayOfPreviousMonth,"d
mmm yyyy")#</cfoutput><br>
</p> -
Last day of previous month for data load
Hi,
I have to load data from the previous month into the psa and then into an infocube. I was wondering as to how to get the last of the previous month to write a code in ABAP. I will be writing the code at the infopackage level in the data selection. I could load data from the 1st of the previous month to the 1st of the current month. This will be an additional load of 30,000 records for the 1st of every month, since I will be loading 30,000 records everyday, I was wondering if I could limit the load from the 1st of every previous month to the last day of that month. This will be a repetitive loading.
DATA: CURR_MM(2) TYPE N,
CURR_YYYY(4) TYPE N,
CURR_DD(2) TYPE N,
PREV_MM(2) TYPE N,
PREV_YYYY(4) TYPE N,
PREV_DD(2) TYPE N,
YYYY_MM(6),
YYYY_MM1(6),
DATE LIKE SY-DATUM.
DATE = SY-DATUM.
CURR_YYYY = DATE+0(4).
CURR_MM = DATE+4(2).
CURR_DD = DATE+6(2).
PREV_DD = 1.
IF CURR_MM = '01'.
PREV_MM = '12'.
PREV_YYYY = CURR_YYYY - 1.
ELSE.
PREV_MM = CURR_MM - 1.
PREV_YYYY = CURR_YYYY.
ENDIF.
concatenate PREV_YYYY PREV_MM PREV_DD into YYYY_MM.
concatenate CURR_YYYY PREV_MM PREV_DD into YYYY_MM1.
read table l_t_range with key
fieldname = 'BLDAT'.
l_idx = sy-tabix.
l_t_range-low = YYYY_MM.
l_t_range-high = YYYY_MM1.
l_t_range-sign = 'I'.
l_t_range-option = 'BT'.
modify l_t_range index l_idx.
p_subrc = 0.
Mind you this code will load data from 1st of the previous month to the 1st of current month. I just don't want to load that extra "1st day" of current month data as I have 30,000 records everyday.
Say for example, I want to load data from 1st Mar to 31st Mar or 1st Feb to 28thFeb. How should I modify the above code.
Is there a formula to get the last date of the previous month. That's all I need. This would solve the problem.try this routine. it will return a range from 1st day to end of the month.
DATA: l_s_range TYPE rsr_s_rangesid,
E_T_RANGE TYPE RSR_T_RANGESID.
DATA: year(4) TYPE n,
month(2) TYPE n,
day(2) TYPE n,
ld_keydate TYPE sydatum,
ld_lastday TYPE sydatum.
REFRESH e_t_range.
CLEAR l_s_range.
year = sy-datum(4).
month = sy-datum+4(2).
*Months with 31 days in year
IF month = '01' OR
month = '03' OR
month = '05' OR
month = '07' OR
month = '08' OR
month = '10' OR
month ='12'.
day = '31'.
ENDIF.
*check for leap year: provoking sy-sybrc <> 0
IF month = '02'.
day = '29'.
MOVE: '02' TO ld_keydate+4(2),
year TO ld_keydate(4),
day TO ld_keydate+6(2).
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
date = ld_keydate
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
day = '28'.
ENDIF.
ENDIF.
*months with 31 days in year
IF month = '04' OR
month = '06' OR
month = '09' OR
month = '11'.
day = '30'.
ENDIF.
MOVE: year TO ld_lastday(4),
month TO ld_lastday+4(2),
day TO ld_lastday+6(2).
l_s_range-low = sy-datum.
l_s_range-high = ld_lastday.
l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.
APPEND l_s_range TO e_t_range.
Maybe you are looking for
-
How can I have xml/php feed text to a flash multipage banner?
Hi guys, Wondering if you could help me on this one... I've made a few sites a few years ago with flash CS3/AS2 and using the TextArea as an output for xml content. that really sucked and looked terrible as it flashed white everytime it was loading (
-
Not able to create XML from an existing relational database
Hi, I am trying to create and xml from an existing relational database. I am not able to get any XML data, I receive "XMLTYPE()" as the result. Here's the query - SQL> select o.order_id, XMLELEMENT("order", XMLATTRIBUTES(o.order_id as ID)) AS "result
-
I hava an Audigy 2 ZS Platinum Pro. I formated my HD last night and reinstalled XP. I then installed the new drivers and Media Source 5 and new DTS Neo plugin. But when I tried to install the old Remote Control plugin, it didn't work, it said I don't
-
Hi, I have this case : I have several invoices for one vendor. Each invoice has a different business area. Invoice 1 - BA = 001 - 1000 Invoice 2 - BA = 001 - 500 Now the point is that when I run the F110 for this vendor, the system group all invoices
-
How to install only java plugin without installing jre
Hello friends, I wanted to know if there is any way one can install java plugin in windows without need to install the entire JRE Thanks in advance, Mayank Johri