How to get first and last date of previous month
To set default values in selection screen,I want first and last date of the previous month.
Also I want the first and last dates of previous quarter.
The quarters can be only january to march, apr to june, jul to sept, oct to dec.
I want to run a program on beginning of each month by job scheduling having <b>selection screens</b> for the above monthly and quarterly dates.
Hi Suhas,
Use the below code.
DATA: v_date LIKE sy-datum.
DATA: v_month_begin_date TYPE sy-datum,
v_month_end_date TYPE sy-datum,
v_month(2) TYPE n,
v_month1(2) TYPE n,
v_quarter TYPE i,
v_year(4) TYPE n,
v_quarter_begda TYPE sy-datum,
v_quarter_endda TYPE sy-datum.
v_month = sy-datum+4(2).
IF v_month = '01'.
v_month = '12'.
v_year = sy-datum+0(4) - 1.
ELSE.
v_month = v_month - 1.
v_year = sy-datum+0(4).
ENDIF.
CONCATENATE v_year v_month '01' INTO v_date.
CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'
EXPORTING
iv_date = v_date
IMPORTING
ev_month_begin_date = v_month_begin_date
ev_month_end_date = v_month_end_date.
v_month1 = sy-datum+4(2).
IF v_month1 = '01' OR
v_month1 = '02' OR
v_month1 = '03'.
v_quarter = 1.
ELSEIF v_month1 = '04' OR
v_month1 = '05' OR
v_month1 = '06'.
v_quarter = 2.
ELSEIF v_month1 = '07' OR
v_month1 = '08' OR
v_month1 = '09'.
v_quarter = 3.
ELSEIF v_month1 = '10' OR
v_month1 = '11' OR
v_month1 = '12'.
v_quarter = 4.
ENDIF.
IF v_quarter = 1.
v_quarter = 4.
v_year = sy-datum+0(4) - 1.
ELSE.
v_quarter = v_quarter - 1.
v_year = sy-datum+0(4).
ENDIF.
CALL FUNCTION 'HR_99S_GET_DATES_QUARTER'
EXPORTING
im_quarter = v_quarter
im_year = v_year
IMPORTING
ex_begda = v_quarter_begda
ex_endda = v_quarter_endda.
WRITE:/5 'previous month begin date : ', v_month_begin_date.
WRITE:/5 'previous month end date : ', v_month_end_date.
WRITE:/5 'previous quarter begin date : ', v_quarter_begda.
WRITE:/5 'previous quarter end date : ', v_quarter_endda.
Message was edited by:
Velangini Showry Maria Kumar Bandanadham
Similar Messages
-
Getting first and last dates of a month
Jello all,
I am really sorry I am posting this topic here, not actually owned by this forum but in fundamental forum i am not getting it attended.
I am generating monthly, quartelry and yearly reports, for which I need to get first and last dates of a given Month taking in to account leap year. I searched the API and docs for Calendar class. I could not find any useful methods / fields. I wonder this being a very common requirement, how SUN has not provided these essential features. I still feel, it must be some where. Please help me and reply. Also if you came across any other forum for util package, let me know.
Thanks
VardeJello all,
I am really sorry I am posting this topic here, not
actually owned by this forum but in fundamental forum
i am not getting it attended.
Yes, and I can see you are a very patient person, waiting a whole half hour for a response before cross posting other boards.
Question answered.
http://forum.java.sun.com/thread.jsp?thread=514908&forum=31&message=2451646 -
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. -
Get first and last date of month
Hi,
Is there any function module to get first and last date of month for a entered date.
Please let me know.
Regards,
SPHi,
Use the below FM to find the Last day of month and them u can easily calculate the first day.
DATA : v_startdate TYPE sy-datum.
DATA : v_enddate TYPE sy-datum.
DATA : v_temp TYPE dats.
v_temp = sy-datum.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
day_in = v_temp
IMPORTING
last_day_of_month = v_enddate
CONCATENATE v_enddate+0(6) '01' INTO v_startdate.
Hope it helps.
Regards,
Arnab. -
How to find first and last date of a fiscal week using SQL
Hello,
I want information about FISCAL Week, means a Week based on ISO standard. I know format strings ‘IW’ or ‘IYYY’ gives fiscal week and fiscal year respectively from a given date. But I want to find the first and last date of a fiscal week. Say suppose I have a fiscal week is 2, and fiscal year is 2008, how to find the start and end date of the given fiscal week.
Any kind of help would be greatly appreciable.
Thanks,
Princedavide gislon wrote:
The following query evaluate the begin of a fisical week, where &year and &week are respectively the year and week you want to calculate.
To evaluate the end of the week you have to add 6.
Note that my database is set to have monday as day number 1 of the week, and sunday as day number 7; if your database settings are different you should modify the query accordingly.
SELECT CASE TO_CHAR(TO_DATE('&year','YYYY'),'D')
WHEN '1' THEN TO_DATE('&year','YYYY')+((&week-1)*7)
WHEN '2' THEN TO_DATE('&year','YYYY')+((&week-1)*7-1)
WHEN '3' THEN TO_DATE('&year','YYYY')+((&week-1)*7-2)
WHEN '4' THEN TO_DATE('&year','YYYY')+((&week-1)*7-3)
WHEN '5' THEN TO_DATE('&year','YYYY')+((&week-1)*7+3)
WHEN '6' THEN TO_DATE('&year','YYYY')+((&week-1)*7+2)
WHEN '7' THEN TO_DATE('&year','YYYY')+((&week-1)*7+1)
END BEGIN_FISICAL_WEEK
FROM DUAL
Hope this is helpful.
Cheers,
Davide
Edited by: davide gislon on 08-Jan-2009 07:19Your query does nothing you say it does. TO_DATE('&year','YYYY') returns first day of the current month for year &year. And the only reason it returns January 1, &year is that we are currently in January:
SQL> select TO_DATE('&year','YYYY') from dual
2 /
Enter value for year: 2005
old 1: select TO_DATE('&year','YYYY') from dual
new 1: select TO_DATE('2005','YYYY') from dual
TO_DATE('
01-JAN-05
SQL> As soon as we roll into February:
SQL> alter system set fixed_date = '2009-2-1' scope=memory
2 /
System altered.
SQL> select sysdate from dual
2 /
SYSDATE
01-FEB-09
SQL> select TO_DATE('&year','YYYY') from dual
2 /
Enter value for year: 2005
old 1: select TO_DATE('&year','YYYY') from dual
new 1: select TO_DATE('2005','YYYY') from dual
TO_DATE('
01-FEB-05
SQL> alter system set fixed_date = NONE scope=both
2 /
System altered.
SQL> select sysdate from dual
2 /
SYSDATE
08-JAN-09
SQL> But even if TO_DATE('&year','YYYY') would always return January 1, &year, or you would fix it to TO_DATE('0101&year','MMDDYYYY') it still would be wrong. ISO week rules are
If January 1 falls on a Friday, Saturday, or Sunday, then the week including 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 week is the first week of the new year, because most of the days in the week belong to the new year.Therefore, next year:
SQL> DEFINE YEAR=2010
SQL> DEFINE WEEK=1
SQL> ALTER SESSION SET NLS_TERRITORY=GERMANY -- enforce Monday as first day of the week
2 /
Session altered.
SQL> SET VERIFY OFF
SQL> SELECT CASE TO_CHAR(TO_DATE('0101&&year','MMDDYYYY'),'D')
2 WHEN '1' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7)
3 WHEN '2' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7-1)
4 WHEN '3' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7-2)
5 WHEN '4' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7-3)
6 WHEN '5' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7+3)
7 WHEN '6' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7+2)
8 WHEN '7' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7+1)
9 END BEGIN_FISICAL_WEEK
10 FROM DUAL
11 /
BEGIN_FI
04.01.10
SQL> SELECT TRUNC(TO_DATE('0101&&year','MMDDYYYY'),'IW') FROM DUAL
2 /
TRUNC(TO
28.12.09
SQL> 2 user10772980:
Use:
SELECT TRUNC(TO_DATE('0101&&year','MMDDYYYY'),'IW') + (&&week-1)*7 FISCAL_YEAR_&&YEAR._WEEK_&&WEEK
FROM DUAL
FISCAL_YEAR_2010_WEEK_1
28.12.09
SQL> SY. -
How we claculate the first and last date of the month
hi,
I have a requirement, if i have the any date of a month like today date 02/13/2008. So i want the first date of this month and the last date of this month.
Is there any FM for this..or if you have nay prorgam pls send to me.
thanks.Hi Vipin,
Try
HR_JP_MONTH_BEGIN_END_DATE FM will return both first day and last day
LAST_DAY_OF_MONTHS for getting last day of month.
Reward if helpful.
Regards,
Mandeep -
First and Last date of any Month.
Hi Friends,
I have 2 fields in my table
FROM DATE & TO DATE
User can enter any date in these two fields, but at time of commit i want to change the FROM DATE to the first date of the Month user have entered. And for TO DATE i want to change the last date of the month.
For Example :
User Enters-
FROM DATE 12-Mar-2003
TO DATE 27-Jun-2003
I want to change these date to:
FROM DATE 01-Mar-2003
TO DATE 30-Jun-2003
How can I write a database function or procedure to control this thing.
Please help.
Best regards,
Imran BaigIt depends on your requirements, but I usually use TRUNC(date, 'D')
to get the first day(Sunday) of the week, because TRUNC(date, 'W')
returns the same day of the week as the first day of the month.
See http://download-west.oracle.com/docs/cd/A87860_01/doc/server.817/a85397/function.htm#80101
for more info on this. -
To display first and last dates of a month
I have the date format in 10 Mar 10.
My requirement is when ever I select the any date in the dashboard for whole month it should display whole month results.
I got query in obiee101.blogspot.com.but if I use that sometimes it is not returning the last day results. Any body please give me the query to display results for first day and lastday?
Ex:if I select any day in the drop down of the prompt it should display whole month results
If I select either 1 mar 10,2 mar 10,30 mar 10.....
It should give the results for whole month of march.
Can you please provide me the query for last month also?
If I select march date in date print want to display whole march results in one column,previous month results in other column
Anybody help me to get this done?Yes, you are correct. In John's SQL for last day of the month, if the "last day of the previous month" ends on the 30th, than "adding one month" will result in the 30th of the following month. But if the following month has 31 days, you miss that day.
Use this for the last day of the current month.
TIMESTAMPADD(SQL_TSI_DAY, -1,TIMESTAMPADD(SQL_TSI_MONTH,1,TIMESTAMPADD(SQL_TSI_DAY,1,TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE))))
The above SQL will ensure that you will always get the last day of the "current month" regardless of how many days are in the previous or current month. -
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> -
Get First and last day of Month..
Hi Friends,
I am trying to fetch First and Last day of a month and would like to implement that in the following code:
SELECT COALESCE(Date_A, Date_B, Date_C)
FROM dual
Here Date A and B are in Format of MM DD YYYY (March 14, 2008)
and Date C is like MM YYYY (March 2008)
How can I get the Date_C as March 1, 2008 OR March 31, 2008 format if Date A and B are NULL ?
Thanks!
Edited by: user11095386 on Apr 23, 2009 10:45 AMHi,
In my earlier message, I thought that you were starting with strings like '03 12 2009' and that you wanted to display them as 'March 12 2009'. If what you have is just the reverse, then just reverse the format strings in my first message. Add a comma, if you want one, in the appropriate format string.
I believe this is what you want:
COALESCE ( TO_CHAR ( TO_DATE ( Date_A, 'fmMonth DD YYYY'), 'MM DD YYYY')
, TO_CHAR ( TO_DATE ( Date_B, 'fmMonth DD YYYY'), 'MM DD YYYY')
, TO_CHAR ( TO_DATE ( Date_C, 'fmMonth YYYY'), 'MM DD YYYY')
)Notice how, on the 3rd line, TO_DATE is called without DD in the format string:
TO_DATE ( Date_C, 'fmMonth YYYY')When you do this, the day defaults to the 1st of the month, so this is all you have to do to convert the VARCHAR2 'March 2009' to the DATE 01-Mar-2009.
If you want the last day of the month, not the first, when Date_C is chosen, then use LAST_DAY:
COALESCE ( TO_CHAR ( TO_DATE ( Date_A, 'fmMonth DD YYYY'), 'MM DD YYYY')
, TO_CHAR ( TO_DATE ( Date_B, 'fmMonth DD YYYY'), 'MM DD YYYY')
, TO_CHAR ( LAST_DAY ( TO_DATE ( Date_C
, 'fmMonth YYYY'
, 'MM DD YYYY'
) -
First and Last Date. Is is possible in Essbase?
Hello All,<BR><BR>Here are the dimensions in my outline:<BR>- User<BR>- Application<BR>- Dates<BR>- Measures (Count, FirstLoginDate, LastLoginDate)<BR><BR>I am trying to create a report in Essbase that shows the first and last date that each user accessed each Essbase application. I created an ETL process that builds a relational table with one record for each unique combination of User/Application/Day where a user was logged into an application. This process gets its source data from the Essbase application log files. I am loading a count of 1 to each intersection of User/Application/Day. I also want to add the first and last day to the cube but can not figure out how.<BR><BR>1) Is there an easier way to get at the source data then the application log files?<BR>2) If the application log files are the way to go, how do I indicate in the cube what the first and last login days are for each combination of User/Application?<BR><BR>I was thinking of loading the serial dates to the FirstLoginDate and LastLoginDate measures. The trouble I am having is where to load the dates data. Do I load it to level 0 (individual dates) and then use time balance to get the dates up to the higher levels (month, year) or load it at the higher levels? If I should load it at the higher levels, do I assume correctly I will need to create another relational table with one record for each User/Application/Month and User/Application/Year that shows the first and last dates? Any other ideas?<BR><BR>Thank you in advance,<BR><BR>Bill Handelman<BR>847-989-1758<BR>[email protected]<BR><BR>
While you may have natural ordering in your date dimensions, Essbase doesn't handle first and last dates well. The one area where ther is at least some funcionality in date manipulation is inattribute dimensions, however, the easy use there allows only one date attribute using normal date processing. It gets a great deal more complex using two dates.<BR><BR>Look up the DBAG references to the date type of attribute dimensions, you might find it a partial solution to your problem.<BR><BR>If you go the serial date method, load at level 0 and want to use time balance to bring the values up, you still need a time dimension. If I were designing something, I might use the first access date as a time dimension and the last access date in an attribute dimension, but I'm rambling rather than analyzing.<BR><BR>In any case, look at the date type attribute dimension as one possible option for your cube.
-
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. -
Function Module to get BEGIN and END date of a month?
Hello everybody,
Is there any function module to get BEGIN and END date of a month
GIVEN EITHER THE CURRENT SYSTEM DATE or MONTH?
Regards,
Sanghamitra.A.hi
CALL FUNCTION 'PA03_PERIODDATES_GET'
EXPORTING
f_abkrs = p_abkrs1
IMPORTING
f_permo = wf_permo
f_current_begda = wf_begda
f_current_endda = wf_endda
CHANGING
f_current_period = wf_pabrp
f_current_year = wf_pabrj
EXCEPTIONS
pcr_does_not_exist = 1
abkrs_does_not_exist = 2
period_does_not_exist = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
this is the function module to get the first date and last date of a particular month
if u have any doubts ask
regads
karthik
reward points if useful -
FM to get start and end date when given month
Hi all,
can anybody help me if there a FM to get start and end date when given month like 01 for jan.
Thanks in advance
SahityaHi,
Check this Function Module
HR_JP_MONTH_BEGIN_END_DATE
here if you r giving the month u wil get the start date and the end date.
Hope this helps you.
Thanks & regards,
Y.R.Prem Kumar -
Variable last date of previous month/last date of current month
Hello Experts,
I am facing an issue while designing a query.
Requirement is like this.
Report will be run on monthly basis.so on execution of report, it should prompt for month/year.
now on report there are two columns for which I have to get data on date basis(last date of previous month and Last date of current month).
Can anyone tell me is there any standard variable for this? what is it?
or how to achieve this?
Regards,
NiravHi,
See if this post in this forum can help you.
Re: Last date of a month
Regards
Shalabh Jain
Maybe you are looking for
-
Have iphone 4 with no sim card. so contacted vodafone whom i have a contract with and arranged to transfer my existing mob num to a micro sim card to use in apple iphone4 . Once received connected to itunes .. picked up the iphone but said iphone was
-
Hi... We have a webi report which is build from two databases.one is oracle and the other is sybase. So the common objects are merged.As they are merged it gives me all the values from both the databases.But i need to have a column in such way that i
-
Need help in automating text from xml into illustrator
I have seen some examples of automation script for filling text from xml into illustrator, need some help in this matter. Need script (currently working in mac OS)
-
How to hide installbase components in SAP CRM 2007 on UI screen
Hi Experts, How to hide Installbase and its Components on UI Screen of SAP CRM 2007.In which BSP component Installbase and its components are there and how to remove it.Advanced thanks for suggestions. Regards Krish
-
Airport is always connected yet internet is only working sporadically
Sup! I need help! I'm calling upon all MacLovers, Macinado's and Jedi MACsters! So the stupid airport is connected yet the internet is only working when it wants to. I know right! ahhh! It's working then it's not then it's working bah stupid jerk. I