No of days in selected month
This query is working fine but I want to use no of days in month despite of sysdate.
bert_date date,
select sum(total_hours)THRS,
sum(nvl(total_hours,0)) / ((sysdate - Min(bert_date))*24) *100 JtOcp
from cargo_handle
where TO_CHAR(bert_date,'fmmonth-Fmyyyy')=LOWER(:dd)((sysdate - Min(bert_date))*24) -- calculating the days
Hi,
LAST_DAY can give you the number of days in a month:
MHO%xe> select add_months(sysdate, level ) dt
2 , to_char(add_months(sysdate, level ), 'Month', 'nls_date_language=american') Mnth
3 , to_number(to_char(last_day(add_months(sysdate, level )), 'dd')) days_in_mnth
4 from dual
5 connect by level <= 12
6 /
DT MNTH DAYS_IN_MNTH
28-08-2009 13:53:18 August 31
28-09-2009 13:53:18 September 30
28-10-2009 13:53:18 October 31
28-11-2009 13:53:18 November 30
28-12-2009 13:53:18 December 31
28-01-2010 13:53:18 January 31
28-02-2010 13:53:18 February 28
28-03-2010 13:53:18 March 31
28-04-2010 13:53:18 April 30
28-05-2010 13:53:18 May 31
28-06-2010 13:53:18 June 30
28-07-2010 13:53:18 July 31
12 rijen zijn geselecteerd.
Similar Messages
-
Returning all the days in selected Month in a Year using Report Builder
I am working Report Builder with SharePoint List Data Source. Report builder has to parameters Month and Year. If i select month as March and year as 2014 the report have to display
March 1 2014 Saturday
March 2 2014 Sunday
March 3 2014 Monday
March 31 2014 Monday
Can any one help on this, do i have to write this in Dataset Property query, Report Builder Properties or calling any function.....!
Appreciate if any example query. Thank youHi SPBee,
If the all fields are already returned by dataset with SharePoint List Data Source, we can directly add filters in your dataset to achieve your requirement.
Expression: [Month]
Operator: In
Value: [@Month]
Expression: [Year]
Operator: In
Value: [@Year]
If you want to create a report that display the data as you post, we can create a function in SQL Server Management Studio as below:
IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME ='CalendarTable1' AND ROUTINE_SCHEMA = 'dbo' AND ROUTINE_TYPE='FUNCTION')
DROP FUNCTION dbo.CalendarTable1
GO
CREATE FUNCTION dbo.CalendarTable1
@StartDate datetime,
@EndDate datetime,
@WeekDaysOnly bit = 0,
@MonthStart bit=0
RETURNS @CALENDAR TABLE
Date datetime,
[Monthname] varchar(20),
[Dayname] varchar(20),
[Day] int
AS
BEGIN
;With Calendar_CTE (Date,[Monthname],[Dayname],[Day])
AS
SELECT @StartDate,datename(Month,@StartDate), DATENAME(dw,@StartDate), DATEPART(day,@StartDate)
UNION ALL
SELECT DATEADD(dd,1,Date),datename(month,DATEADD(dd,1,Date)), DATENAME(dw,DATEADD(dd,1,Date)) ,
DATEPART(day,DATEADD(dd,1,Date))
FROM Calendar_CTE
WHERE DATEADD(dd,1,Date) < = @EndDate
INSERT INTO @CALENDAR
SELECT Date,[monthname],[Dayname],[Day]
FROM Calendar_CTE
RETURN
END
Create two parameters start and end with Date/Time type in the report, then use the query like below in the dataset:
SELECT * from dbo.CalendarTable1 (@start,@end,0,0)
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Show all days in a month select
hello
i have a ckeckin - checkout table as
id number pk,
emp_id number fk,
checkin date , -- user date enters
checkout date -- user logsout
totalhours number ,
totalminutes number,
state varchar2(3) default 'in'
it keeps totalhours and mins of an employer .i need
a select based on that table of one month
but i want to see the days in the month
(if a user did not enter one day iwant to see o hours , 0 minutes )
select totalhours , totalminutes , checkindate
from checkin_table
where to_char(checkindate,'mon')='FEB'
and emp_id='2'
order by checkindate
and i need something like
7,59, 1-feb
0,0,2-feb
0,0,3feb
8,04,4-feb
best regards
Aris dc
andWhat I like in that case is the pipelined function. You can see an example usage Re: Can a view be created within the BEGIN and END block of a procedure
Nicolas. -
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. -
Successive dates with last day of that month being added to succesive date
Hi ,
I have a piece of code that displays the succuessive dates from the given date to tilll date with a date interval of 30 days. My requirement goes some thing like this. since the given date is '26-nov-08' the next successive date should be the number of days in nov(30) added to '26-nov-08'. that will be around 26-dec-08. For this date it has to add the number of days in December(31) to '26-dec-08' and that turns out to be '26-jan-09'. and this must go on till date.
In the below code i have used 30 for the interval of 30 days but the interval has to the last day of the successive date's month( for dec the interval has to 31 and for january the interval has to be 31 and for february 28)
select to_date('26-nov-08', 'dd-mon-yy') + (level - 1) * 30
from dual
connect by level <= trunc((sysdate-to_date('26-nov-08', 'dd-mon-yy'))/30 )Please advicehi ,
the query sent by you is correct and could it be in corporated for this query :
SELECT TRUNC(inst_due_date) + (LEVEL-1 ) * (ilpa_term_type),iloan_code,LOAN_AMT,FEE_AMT,
LOAN_DATE,LOAN_STATUS_ID
FROM (
SELECT inst_due_date,sm.iloan_code,LOAN_AMT,
FEE_AMT,
LOAN_DATE,
LOAN_STATUS_ID,
decode(sm.ilp_term_type, 26 ,14,24,15,12,(select to_number(to_char(last_day(inst_due_date),'dd')) from dual)) as ilpa_term_type
FROM ST_IL_SCHEDULE sc,ST_IL_MASTER sm
WHERE sc.iloan_code = sm.iloan_code
AND sc.inst_num = (SELECT MAX(inst_num) FROM ST_IL_SCHEDULE b WHERE b.iloan_code = sc.iloan_code)
AND sc.iloan_code =123456789)
CONNECT BY LEVEL <= TRUNC((TRUNC(SYSDATE)-TRUNC(inst_due_date))/(ilpa_term_type) )
Here we are using the decode concept if ilp_term_type = 26 then 14 but we need to implement the code of adding the number of days to that month in place of this code :
select to_number(to_char(last_day(inst_due_date),'dd')) from dual:
Please advice -
How do I add a recurring event to repeat on the fifth recurring day of the month, for example, an event that only happen on the fifth Sunday of the month for those months that have a fifth Sunday?
Create one on the first Tuesday, select repeat/monthly and take the option at the bottom.
-
View Outlook Calendar on iPhone In Day, Week, Or Month Views--NOT As A List
I apologize in advance if this has been asked already but couldn't find the answer after an extensive search.
My question is, after syncing my Outlook calendar to the iPhone, how can I view my appointments other than as a list in the iPhone? I would like to view my appointments in either day, week, or month views as opposed to only knowing what my next two or three appointments are. To me it just seems like a simple setting I'm overlooking somewhere. I appreciate any help you can afford
Thanks in advance,
-V5*iPhone calendar views are a joke!*
My 90's Palm Vx had far more usable views via Pimlico Software. The gray scale display with poor resolution was able to show one or even two weeks with appointment texts.
What does iPhone have? List view is the best there is. One sees all appointments with only just scrolling. Day view is terrible. The whole day should be visible without scrolling for it to be at least somewhat efficient. Now one has to first select a day with arrows and after that scroll thru the day and after that select another day and scroll again. No way. Month view is very poorly designed! The grid takes way too much space and who decided to put the appointment list in the bottom of the screen when one's index finger blocks it if sliding thru days in the grid!!! Oh man!!! Unlock the landscape view and please make the grid a little bit smaller and please place the appointment list on the left or at least on the right side. And make its font way smaller! No point in seeing two appoinments without scrolling.
iPhone's wonderful screen would be able to show one or two weeks with written appointments in a list like manner especially landscape. I mean seven columns titled Mo-Su and all appointments listed in that day's column.
Hopefully SDK will let someone else do it if Apple won't.
And we have to get to copy appointments and paste them to other days also. I am spending 30 min writing the same info one at a time to our monthly plan. Everyone else is already having a cup of coffee. -
I want to count the number of days for a month using sysdate and then multiply it with an amount. how do i do that . for eg
if my sysdate is 27th june then june being a 30 days month i need to multiply 30 with the ammount.
Ammount * 30.
if my sysdate is 27 feb then i need to count the no of days in the month that is 28 (if its a leap year then 29) and then multiply amount * 28.
How do i achive this in my formula .
Please help thanksMay be this?
select to_char(Last_day(sysdate),'DD') * amount FROM table -
ABAP for the first day of the month
Hello BW users,
I have a scenario which uses an ODS with cumulative key figures with Addition update type. An infocube gets data from ODS by start routine in cube's update rule. I update this ODS first then infocube. All the loads are Full and are loaded daily. This is a snapshot scenario and I load the ods on itself then load from another infocube let's say Cube1. After successful load, I update infocube on itself again then update from the same infocube, Cube1, as in ODS. Infocube load sequence is same as ODS. In the scenario ODS and infocube are wanted to be updated daily. Therefore, I have to delete the ODS's (since it is addition update type) and infocube's overlapping data in the process chain that automates the load. At this point I need two things:
1- ABAP program that is going to give me the first day of each month.
2- ABAP program that is going to delete the overlapping data in ODS when I load it daily. Since I can do that for infocube in process chain with standard process type of Delete overlapping requests from infocube I need it only for ODS. Because there is no standard process type to delete overlapping requests in ODS (since its update type is Addition).
I appreciate your help. Thank you in advance.
Sincerely,1- ABAP program that is going to give me the first day of each month.
if sy-datun+6(2) = 01.
SY-FDAYW should give you the day
endif.
2- ABAP program that is going to delete the overlapping data in ODS
REPORT <PGM NAME>.
TABLES: RSODSACTREQ , rsseldone.
Parameters : odsname type RSINFOCUBE default '<>ODS NAME'.
DATA: temp_REQUEST LIKE RSODSACTREQ-REQUEST,
temp_REQUEST1 LIKE RSODSACTREQ-REQUEST,
temp_RNR LIKE rsseldone-RNR.
DATA: BEGIN OF itab OCCURS 0,
REQUEST LIKE RSODSACTREQ-REQUEST,
TIMESTAMP LIKE RSODSACTREQ-TIMESTAMP,
END OF itab.
DATA: BEGIN OF itab1 OCCURS 0,
RNR LIKE rsseldone-RNR,
seldate LIKE rsseldone-seldate,
seltime LIKE rsseldone-seltime,
END OF itab1.
SELECT REQUEST TIMESTAMP FROM RSODSACTREQ INTO TABLE itab
WHERE ODSOBJECT = '<ODS NAME>'.
SORT itab DESCENDING BY TIMESTAMP .
READ TABLE itab INDEX 1.
temp_REQUEST = itab-REQUEST.
SELECT RNR seldate seltime FROM rsseldone INTO TABLE itab1
WHERE source = '<Info Source Name for the ODS>'.
SORT itab1 DESCENDING BY seldate seltime .
READ TABLE itab1 INDEX 1.
temp_RNR = itab1-RNR.
*If temp_REQUEST = temp_RNR .
CALL FUNCTION 'RSSM_PROCESS_REQUDEL_ODSO'
EXPORTING
I_ODS = odsname
I_REQUEST = temp_REQUEST
I_JOBNAME = 'i_jobname'
I_VARIANT =
I_INSTANCE =
IMPORTING
E_ERROR =
E_T_MSG = itab1
E_T_RNRLIST = ITAB1.
*else.
*raise exception.
*endif.
clear itab.
refresh itab.
SELECT REQUEST TIMESTAMP FROM RSODSACTREQ INTO TABLE itab
WHERE ODSOBJECT = '<ODS NAME>'.
SORT itab DESCENDING BY TIMESTAMP.
READ TABLE itab INDEX 1.
temp_REQUEST1 = itab-REQUEST.
if temp_REQUEST = temp_REQUEST1.
raise exception .
endif. -
Count days in a month for a date range
i am trying to find no. of days between 2 Date Ranges for a list of Ids. i used the logic in the below link:
count days of the month
My query is giving duplicates since, I have list of Ids.
Doctor_ID Patient_ID ARRIVE_DT_TM DISCH_DT_TM
755722 42972229 10/18/2012 7:50 3/14/2013 20:45
763305 42972232 1/7/2013 20:27 3/15/2013 19:15
25391509 42972298 2/4/2013 22:45 3/8/2013 22:03
746779 42972331 1/4/2013 23:00 3/26/2013 21:50
763305 42972338 3/4/2013 22:19 3/6/2013 19:35
763305 42972411 11/4/2013 22:32 3/29/2013 17:30
I am looking for query to give me for Patient_ID = 42972229
MONTH COUNT_DAYS
201210 14
201211 30
201212 31
201301 31
201302 28
201303 14
I am running the following code and it loops through the months and gives duplicates when I remove where Patient_id IN (42972229)
select
Doctor_ID
, Patient_ID
, AR_DTTM
, DSC_DTTM
, TO_CHAR(ADD_MONTHS(TRUNC(date1, 'MONTH'), LEVEL - 1), 'YYYY MM') MONTHS_BET
, (LEAST(date2, ADD_MONTHS(TRUNC(date1, 'MONTH') - 1, LEVEL)) - GREATEST(date1, ADD_MONTHS(TRUNC(date1, 'MONTH'), LEVEL - 1)))+ 1 AS DAYSCOUNT
from (select
Doctor_ID
, Patient_ID
, ARRIVE_DT_TM AR_DTTM
, DISCH_DT_TM DSC_DTTM
,TRUNC(ARRIVE_DT_TM,'DDD') AS date1
,TRUNC(DISCH_DT_TM,'DDD') AS date2
from temp where Patient_id IN (42972229)
CONNECT BY LEVEL <= MONTHS_BETWEEN(TRUNC(date2, 'MONTH'), TRUNC(date1, 'MONTH')) + 1
Please help!Hi,
ASTRA_007 wrote:
Results I would like to see are:
Doctor_ID Patient_ID ARRIVE_DT_TM DISCH_DT_TM Month CountofDays
755722 42972229 10/18/2012 7:50 3/14/2013 20:45 2012 10 14
755722 42972229 10/18/2012 7:50 3/14/2013 20:45 2012 11 30
755722 42972229 10/18/2012 7:50 3/14/2013 20:45 2012 12 31
755722 42972229 10/18/2012 7:50 3/14/2013 20:45 2013 01 31
755722 42972229 10/18/2012 7:50 3/14/2013 20:45 2013 02 28
755722 42972229 10/18/2012 7:50 3/14/2013 20:45 2013 03 14
763305 42972232 1/7/2013 20:27 3/15/2013 19:15 2013 01 25
763305 42972232 1/7/2013 20:27 3/15/2013 19:15 2013 02 28
763305 42972232 1/7/2013 20:27 3/15/2013 19:15 2013 03 15
and so on...So each row represents a patient-month, and you want to display several columns from the temp table on each output row. In that case, include all those columns in both the SELECT and GROUP BY clauses, like this:
WITH universe AS
SELECT *
FROM temp
-- WHERE patient_id IN (42972229)
, date_range AS
SELECT TRUNC (MIN (arrive_dt_tm)) AS first_date
, TRUNC (MAX (disch_dt_tm)) AS last_date
FROM universe
, all_dates AS
SELECT first_date + LEVEL - 1 AS a_date
FROM date_range
CONNECT BY LEVEL <= (last_date + 1) - first_date
SELECT u.doctor_id
, u.patient_id
, u.arrive_dt_tm
, u.disch_dt_tm
, TO_CHAR ( TRUNC (a.a_date, 'MONTH')
, 'YYYY MM'
) AS month
, COUNT (*) AS count_days
FROM all_dates a
JOIN universe u ON a.a_date BETWEEN TRUNC (u.arrive_dt_tm)
AND u.disch_dt_tm
GROUP BY u.doctor_id
, u.patient_id
, u.arrive_dt_tm
, u.disch_dt_tm
, TRUNC (a.a_date, 'MONTH')
ORDER BY u.patient_id
, TRUNC (a.a_date, 'MONTH')
;Output from your sample data (with no filtering):
`DOCTOR_ID PATIENT_ID ARRIVE_DT_TM DISCH_DT_TM MONTH COUNT_DAYS
755722 42972229 10/18/2012 7:50 3/14/2013 20:45 2012 10 14
755722 42972229 10/18/2012 7:50 3/14/2013 20:45 2012 11 30
755722 42972229 10/18/2012 7:50 3/14/2013 20:45 2012 12 31
755722 42972229 10/18/2012 7:50 3/14/2013 20:45 2013 01 31
755722 42972229 10/18/2012 7:50 3/14/2013 20:45 2013 02 28
755722 42972229 10/18/2012 7:50 3/14/2013 20:45 2013 03 14
763305 42972232 1/7/2013 20:27 3/15/2013 19:15 2013 01 25
763305 42972232 1/7/2013 20:27 3/15/2013 19:15 2013 02 28
763305 42972232 1/7/2013 20:27 3/15/2013 19:15 2013 03 15
25391509 42972298 2/4/2013 22:45 3/8/2013 22:3 2013 02 25
25391509 42972298 2/4/2013 22:45 3/8/2013 22:3 2013 03 8
746779 42972331 1/4/2013 23:0 3/26/2013 21:50 2013 01 28
746779 42972331 1/4/2013 23:0 3/26/2013 21:50 2013 02 28
746779 42972331 1/4/2013 23:0 3/26/2013 21:50 2013 03 26
763305 42972338 3/4/2013 22:19 3/6/2013 19:35 2013 03 3
In the end the objective is to count the no. of days in each month between the arrival and discharge dates by Physician and for his/her patients.Then is the output above really what you want? Say you're interested in physician 763305. That physician had 18-patient days in March, 2013, but the output doesn't make it clear.
I ran your query, it works great but I have a long list of patients for whom I have to run these counts.the query above includes all patient_ids.
That's a separate problem, to be solved in the first sub-query, universe. The rest of the query will be unchanged.
How will you know which patients to include? If you can derive the list from temp itself, just use a WHERE clause in universe. If you need to look at other tables, join them in universe, or use them in sub-queries in universe, or both.
For exmple, if you decide that the list of patient_ids has no pattern, and that you'll need to store their ids in a separate table (perhaps a global temporary table), then universe might be:
WITH universe AS
SELECT t.* -- or list columns needed
FROM temp t
JOIN patient_ids_to_include p
ON p.patient_id = t.patient_id
) ...The rest of the query can be the same as above.
If a same patient is admitted again then Patient_ID will be different no matter when readmitted.Are you saying that patient_id identifies a visit, not a patient, and that the same person is assigned a different patient_id every time that person is admitted?
For
INSERT INTO temp (doctor_id, patient_id, arrive_dt_tm, disch_dt_tm)
VALUES ( 755722
, 42972229
, TO_DATE ('03/14/2013 23:00', 'MM/DD/YYYY HH24:MI')
, TO_DATE ('04/01/2013 12:00', 'MM/DD/YYYY HH24:MI')
First the Patient ID will be different from the earlier admission. Second the results will show like:
Doctor_ID Patient_ID ARRIVE_DT_TM DISCH_DT_TM Month CountofDays
755722 42972229 3/14/2013 23:00 4/1/2013 12:00 2012 03 14
755722 42972229 3/14/2013 23:00 4/1/2013 12:00 2012 04 1Are you saying that temp.patient_id is unique, and so the situation is impossible?
Edited by: Frank Kulash on May 7, 2013 10:23 AM -
How to create a recurrent event on the first or last work day of the month
The lightning calendar allows selection of the first and last day of the month for recurrent events but for business I need to use the first and last WORK day of the month (Monday - Friday) to schedule particular tasks. In the calendar preferences under 'View' I can select the days that make up the work week but this does not transfer to an option in recurrent events. Is there another way to do this or is it just not available?
Hi there,
do know for the UlltimateBootCD4Win? This from CD bootable WinXP-BartPEedition with additional tools gives you the ability to make such things like partitioning, backup or formatting your HDD.
It has many more applications which help you to maintain your system without booting your original OS.
So I think that this CD will solve your partitioning issues.
Heres a link: www.ubcd4win.com/
Just try it and tell me your opinion.
Nice weekend and greetings from the sunny south ;) -
How to get last day of a month
using pl/sql
What i need is that all members whose birthdate is in the curren month will be included as having had their birthdate regardless of the date of the month. The code i have is:
Select me607.subscriber_id
me607.mbr_dob,
** trunc(months_between (*end of current month*,me607.mbr_dob) / 12) as age
from odw.mbr607_member_expanded me607
The asterixed line is what I need to change. If I put the end of the current month (where I put 'end of current month') then all those whose birthday month is in Feb will show as having had their birthdate. So if run today, folks whose birthdate is 26-feb-2005 will show an age of 5.
When grabbing the last day of the month using visual basic I just use the first day of the subsequent month minus 1. Any assistance is appreciated..Hi,
This does what you requested:
Select me607.subscriber_id, -- Don't you need a comma here?
me607.mbr_dob,
ROUND ( MONTHS_BETWEEN ( SYSDATE
, me607.mbr_dob
/ 12
from odw.mbr607_member_expanded me607
WHERE TO_CHAR (me607.mbr_dob, 'MONTH') =
TO_CHAR (SYSDATE, 'MONTH')
;If this is run sometime in February, 2010, and mbr_dob is sometime in Febrary, 2005, then the result of MONTHS_BETWEEN will be between 59 and 61. When we divide by 12 convert that to years, that difference of up to one month becomes so small that it will be lost in the rounding.
If this isn't exactly what you need, tthen post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
Edited by: Frank Kulash on Feb 17, 2010 1:32 PM
Added explanation. -
I have recently written my first stored procedure.
Its rather a bunch of SQL statements.
I had to hard code lot of dates. most of them are first day of the current monthe or last day of current month etc.
I thot of parametrizing all the dates, but if a business person has to include all the parameters they could go wrong and get the wrong results.
Now, I want to use date functions to achieve these requirements:
Can any one please throw some insght into this:....
1) First day of current month,
2) last day of current month.
3) first day of previious month
4) last day of previous month
5) first day of a month that is 3 months from now.
6) last day of a month that is 3 months from now.
7).....
Can any one please throw some light on any one of this.. I can try to work from there onwards ....
Thanks a lot in advance,
AcHi there,
1) First day of current month
select trunc(sysdate, 'MM') from dual;
2) last day of current month.
select trunc(add_months(sysdate, 1), 'MM') - 1 from dual;
3) first day of previious month
select trunc(add_months(sysdate, -1), 'MM') from dual;
4) last day of previous month
select trunc(sysdate, 'MM') - 1 from dual;
5) first day of a month that is 3 months from now.
select trunc(add_months(sysdate, 3), 'MM') from dual;
6) last day of a month that is 3 months from now.
select trunc(add_months(sysdate, 4), 'MM') - 1 from dual;cheers,
Anthony -
If Current Month then use last day, else use month
My cube is setup where the current month is at a daily level and the previous months just contain the last day of data.
I would like to for the last month to only return the last day and return the month level for all previous months. The reason being is our third party software gives us the capability of doing a drillthrough, but when doing it for the latest month, it is
returning every day in that month.
Here is my attempt, but it is only returning the last month, not the rest of the months.
select [Measures].[Current Balance]
on 0, non empty
[Date].[Month].children
on 1
from [MyCube]
where
IIF([Date].[Month].CurrentMember = ClosingPeriod([Date].[Month].[Month]),
TAIL (NonEmpty([Date].[Date].members,[Measures].[Count Of Accounts]),1),
[Date].[Month].CurrentMember)Hi Dodge,
I’m writing to follow up with you on this post. Was the problem resolved by the above query?
If the issue was solved, I’d like to mark this issue as "Answered". Please also feel free to unmark the issue, with any new findings or concerns you may have.
Thanks,
Charlie Liao
TechNet Community Support -
Elapse days - calculation from month and year
Duplicate thread ...
coding required for converting month into days
I have Month and year field in my DSO --Year( 2009), Month(4)
I want below logic to calculate -
MTD qty % = (qty * elapse days) / no of days in month
so from the above, I want to know,
1. How can we get the no of days from the above 2 objects (year and month).
2. Elapse days are the days that are over from current date to Ist day of that month.
eg: current date - 04.03.2009 , 1st day of the month - 04.01.2009,
elapse days = 2. (you need to consider all days in the month, not only working days)
so my questions is how can we get, # of days n a month from above 2 fields and elapse days based on the above condition.
also want to know, where can I have the logic in transformations or query level.
please provide your suggestions.
Thanks,
Pra
Edited by: Arun Varadarajan on Apr 5, 2009 10:44 PM
Edited by: Arun Varadarajan on Apr 5, 2009 10:45 PMHello,
I think the sample program below does what you ask: it finds the days in the month (bit of an overkill to use function modules for that) and then computes the QTD.
Note that the internal string representation of a data variable is always YYYYMMDD, regardless of the "externalized" form (e.g. yyyy/mm/dd or dd.mm.yyyy), so this code will work regardless of your custom date format.
Regards,
Mark
REPORT zqty_to_date.
PARAMETERS:
p_date TYPE dats,
p_qty TYPE i.
DATA:
days TYPE i,
n_year TYPE numc4,
n_month TYPE numc2,
n_day TYPE numc2,
qtd(6) TYPE p DECIMALS 1.
START-OF-SELECTION.
n_year = p_date+0(4).
n_month = p_date+4(2).
n_day = p_date+6(2).
PERFORM days_in_month USING n_year n_month CHANGING days.
qtd = ( p_qty * ( n_day - 1 ) ) / days.
WRITE: / 'Days in month:', days,
/ 'Qty to date :', qtd.
*& Form days_in_month
* text
FORM days_in_month USING year month CHANGING days.
DATA: ymod4 TYPE i,
ymod100 TYPE i,
ymod400 TYPE i.
CASE month.
WHEN 4 OR 6 OR 9 OR 11.
days = 30.
WHEN 2.
ymod4 = year MOD 4.
ymod100 = year MOD 100.
ymod400 = year MOD 400.
IF ( ymod4 = 0 AND ymod100 > 0 ) OR ( ymod100 = 0 AND ymod400 = 0 ).
days = 29.
ELSE.
days = 28.
ENDIF.
WHEN OTHERS.
days = 31.
ENDCASE.
ENDFORM. "days_in_month
Maybe you are looking for
-
How to use protect and endprotect in smart form
hi to all experts, im still begineer in smart form , i have two headings like company_code: purchase doc no: after this i have a table to be displayed with four columns what i want is the whole data should not be spli
-
How can I click a link to open a new tab without automatically switching to the new tab?
I use Ixquick as my search engine. When the search result comes up, every time I click a link, Firefox creates a new tab and changes the focus from the search results page to the page for the link I clicked. I want to have a new tab created , but I w
-
Dynamic assign in field symbols
dynamic assign in field symbols
-
Invoke node unfonctionnal after compiling
Hello, I'm currently trying to use an invoke node (I'm not using an english LabVIEW so I don't know if the words are exactly the same translated) : Obtain VI / Editor Version When I'm using it in my .VI my project work perfectly, but when I'm trying
-
How do I see my contact list on my iPad?