How to Get days of Month in SSRS
How can I get days of Month in SSRS report...?
Hi RedZinc,
You can do it by writing a SQL query to generate days of month. For doing recursive to generate days,
Use CTE with recursive logic:
Declare @StartDate as DATE, @EndDate as DATE;
SET @StartDate = CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101)
SET @EndDate = CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,Getdate()))),DATEADD(mm,1,Getdate())),101)
;WITH cte AS (
SELECT @StartDate AS myDate
UNION ALL
SELECT DATEADD(Day,1,myDate)
FROM cte
WHERE DATEADD(Day,1,myDate) <= @EndDate
Select * from CTEtested the above sql code and it is working. CTE will be easy to implement recursive stuff.
Maruthi... http://www.msbimaru.blogspot.com/
Similar Messages
-
How to get days and months when two dates are given
Hi All,
I have a requirement where I need to return the number of months and days between given dates.
I dont need to take the year into account as the dates difference is always less than an year
I have 28-jun-2012 and 31-jan-2013 as dates.
I'm working on 10g
when I do select months_between(:a,:b) from dual and provide those dates it gives me 7.09677
I want it to give as 7 months and 9 days or what ever the exact days are.
Your inputs are much appreciatedBluShadow wrote:
874719 wrote:
Thanks a lot,BluShadow for your answer and would you mind giving it for the year as well like 0 years 7 months 3 days?Your original post said:
I dont need to take the year into account as the dates difference is always less than an yearNow you've got the idea, why not have a go yourself first, and then if you're still not getting it, post what you've tried so we can help you.Oh... go on... I'm in a good mood today...
SQL> ed
Wrote file afiedt.buf
1 with t as (select date '2012-06-28' as start_date, date '2013-01-31' as end_date from dual union all
2 select date '2012-02-29', date '2012-06-30' from dual union all
3 select date '2010-02-28', date '2012-06-30' from dual union all
4 select date '2012-02-29', date '2012-06-15' from dual
5 )
6 --
7 select start_date, end_date
8 ,months_between(end_date,start_date) as mnth_bet
9 ,floor(months_between(end_date,start_date)/12) as yr
10 ,floor(mod(months_between(end_date,start_date),12)) as mnth
11 ,case when to_number(to_char(end_date,'DD')) >= to_number(to_char(start_date,'DD')) then
12 to_number(to_char(end_date,'DD')) - to_number(to_char(start_date,'DD'))
13 else
14 (to_number(to_char(last_day(start_date),'DD'))-to_number(to_char(start_date,'DD')))+
15 (to_number(to_char(end_date,'DD')))
16 end as dys
17* from t
SQL> /
START_DATE END_DATE MNTH_BET YR MNTH DYS
28-JUN-2012 00:00:00 31-JAN-2013 00:00:00 7.09677419 0 7 3
29-FEB-2012 00:00:00 30-JUN-2012 00:00:00 4 0 4 1
28-FEB-2010 00:00:00 30-JUN-2012 00:00:00 28 2 4 2
29-FEB-2012 00:00:00 15-JUN-2012 00:00:00 3.5483871 0 3 15 -
How to get the current month number
Hi everyone,
Does anybody know how to get the current month number in Oracle Discoverer Worksheet calculation?
I try to use EUL_DATE_TRUNC(CURRENT_DATE, 'MM'), but instead I got 01-AUG-00.
If I change the data display format to MM, it will give me "08" but if I use TO_NUMBER function to convert it to number I get error "invalid number"
Is there anyway to get the current month value in number? ThanksScott,
Thank you so much! It works perfectly! :)
Hope you have a great day ahead!
Cheers,
Angeline -
How to get days between two dates
Hi ,
How to get days between two dates.
Regards,
Ramesh.Hi Ramesh,
REPORT ZDATEDIFF.
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. -
How to Get the current month at timezone UTC-10
Hi All,
can you please let me know How to Get the current month at timezone UTC-10.
Function module ? which date and time needs to pass.Hi,
Try with following code.
DATA zdate TYPE D.
DATA ztime TYPE T.
CALL FUNCTION 'ISU_DATE_TIME_CONVERT_TIMEZONE'
EXPORTING
x_date_utc = sy-datum
x_time_utc = sy-uzeit
x_timezone = 'UTC-10'
IMPORTING
Y_DATE_LCL = zdate
Y_TIME_LCL = ztime
EXCEPTIONS
GENERAL_FAULT = 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 : zdate, / ztime.
Thank you,
Sekhar. -
How to get the current month value for a customer exit variable?
How to get the current month value for a customer exit variable?
And also if we have an InfoObject with date value (including date, month, year), then how to derive the month value from this date type of Char.?
Thanks!Hi Kevin,
Check here........
Re: Customer Exist for "From Current Date To Month End"
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/25d98cf6-0d01-0010-0e9b-edcd4597335a
Cal month
Regards,
Vijay. -
How to get past four month user history?
Hi ,
can any one help me.How to get past three month details like login and logoff from oracle database
Edited by: 849135 on Mar 31, 2011 11:29 PMHi;
Check our previous discussion thread, if audit mechanisim is not avaliable on your db its ahrd to get all information. But you can get some info from thread which i mention here:
Whether a DB user account has logged in the Oracle database
Re: Whether a DB user account has logged in the Oracle database
Regard
Helios -
How to get day of week from NSDate?
How to get day of week from NSDate?
Here's a way to get the name of the weekday as an NSString if you've already got an NSDate...
NSDate * testDate = [NSDate date];
NSString * weekdayString = [testDate descriptionWithCalendarFormat:@"%A" timeZone:nil
locale:[[NSUserDefaults standardUserDefaults] dictionaryRepresentation]];
NSLog(@"Day of the week: %@", weekdayString);
The output is something like:
Day of the week: Monday
You can use a lower-case "%a" as the descriptionWithCalendarFormat if you just want the three character weekday abbreviation ("Mon", "Tue", "Wed", etc).
Steve -
How to get the count monthly wise
Hi All
I have lot of order dispatched in a year 2010, how to get the moth wise total.
For example jan 1000 orders ,feb 2500 orders.
Thanks & Regards
Srikkanth.MPleiadian wrote:
Maybe even
b.schedule_ship_date between to_date('2010','YYYY') and to_date('2011','YYYY');)But this could return schedule ship dates that are 01-Jan-2011 00:00:00. I don't think this is wanted since it was not specified in the original requirement. I'm not even sure if to_date('2010','YYYY') returns 01. Feb.2010 in a few days (when we will have february).
Just checking the docs....
found it: http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements003.htm#SQLRF51062
from the docs:
If you specify a date value without a time component, then the default time is midnight (00:00:00 or 12:00:00 for 24-hour and 12-hour clock time, respectively). If you specify a date value without a date, then the default date is the first day of the current month.Just to be on the safe side always give the complete format mask!
b.schedule_ship_date >= to_date('01012010','DDMMYYYY')
and b.schedule_ship_date < to_date('01012011','DDMMYYYY')Edited by: Sven W. on Jan 17, 2011 5:14 PM -
How to get the currrent month and year from a new date object
If I create a new Date object as "d",
java.util.Date d = new java.util.Date();how can I format the date to get the current Month as 'Jan' and the current year as '2008'. So if I have something like d.getMonth() gets the current month as 'Oct' and d.getYear() gets '2008'
Thanks,
Zub[Read the flamin' manual you must. Hmm.|http://en.wikipedia.org/wiki/RTFM]
~~ Yoda.
Well no actually, he didn't say that, but he should have.
Cheers. Keith.
PS: Don't say that to a 7 foot pissedOff wookie when he's got his head stuck in a smoking hyperdrive, and you're being chased by a S-class battle cruiser... Ask Yoda how he got to be so short.
PPS: It is the SimpleDateFormat you seek ;-)
Edited by: corlettk on 14/10/2008 22:37 ~~ Also far to slow... but funny. -
How to get the first month of the year inputed by user manually
Hi Expert,
Just like the subject, I 'd like to get the first month of the year inputed by user manually, but don't know how to set the variable, please help.
For example, user execute a query and input the value of variable Year = 2010, and what I want to get is 201001 into another variable, so that I can use this variable to setup another selection.
Thank you.
AndyHi Andy,
1) U will create a user input varaible for year and say it is ZYEAR.
2) U will create another variable for calmonth which has processing type : customer exit ..single value ...mandatory ....say ZCMONTH.
This needs to be populated using the year( user inputted ) and calmonth '001'
This code will fetch the user input value into ZYEAR and append '001' to the user input value and the value
will be passed to the ZCMONTH varaible...
Sample Code is....
When 'ZCMONTH'.
IF I_STEP = 2.
READ TABLE I_T_VAR_RANGE WITH KEY VNAM = 'ZYEAR'.
IF SY_SUBRC = 0.
L_S_RANGE-LOW = I_T_VAR_RANGE-LOW.
L_S_RANGE-LOW+4(3) = '001'.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
APPEND L_S_RANGE TO E_T_RANGE.
ENDIF.
ENDIF.
Regards
vamsi -
How to get day from Week Number
Hi all,
how to get date from the week number when the day is MONDAY.
like : week num =33
how get the date of the day MONDAY from this..SQL> select
to_char(d,'YYYY') y,
w,
trunc((trunc(d,'Y')+w*7-date '1000-01-01')/7)*7+date '1000-01-01' monday
from
(select sysdate d, 33 w from dual);
Y W MONDAY
2005 33 15.08.2005Message was edited by:
Laurent Schneider
I wrote an article which may help you to get out of the mess with weeks that start on friday, saturday, sunday, monday
http://laurentschneider.blogspot.com/2005/07/tochar-d.html -
How to get day if we give the date
i want the day for tghis date(16-march-2006), how to get that
select to_char(sysdate,'day') from dual,it gives the correct day but select to_char('16-mar-06','day') from dual it gives error,
so how to get that dayHi
First convert it '16-MAR-06' to date then give format
select to_char(to_date('16-MAR-06','DD-MON-YY'),'day') from dual;
TO_CHAR(T
thursday
Khuram Siddiqui
[email protected] -
How to get days between 2 dates in jasperreports
hi All
i m not getting how to find days b/w 2 dates in jasper reports.....
here is da detail info....
i am generating jasper reports for transaction in bank
i have to get the days b/w current transaction and last transaction dats way its needed
plz any one help me to get days b/w current and previous transactions...
i m waiting for ur respone....plz.
with regards
kotreshtake a look at Calendar in the API docs.
It should give you some ideas.
If it doesn't, look harder as the answer is right there. -
How to get the current month for a variable based on info object 0FISCPER3
Hie Gurus
I am working on the financial reports i am failing to derive the Current month from the variable based on infobject 0FISCPER3 PERIOD .
I would also like to get the same month from the prevoius year. Any ideas?If I understood correctly, you need in your repot
Current Month Plan This year || YTD Plan This Year || Current Month Plan Last Year || YTD Plan Last Year
Your variable 0I_FISCPER3 must be on the object 0FISCPER3 which is nothing but just the Fiscal Period. This variable is a user entry mandatory Interval variable.
if you are entering a range in the input screen for this variable, you will get cumulative values. If you just need to get the value for a month in first column your report, you will have to create another variable of type Customer Exit which will read the "To value" entered for the variable 0I_FISCPER3 and columns for Current Month should be restricted on this variable.
if you are entering a single value in the selection screen of this variable, current month column should be restricted on this variable with "Equal To" operation and YTD colmns should be restricted to "Less Than Equal to" operator with this variable.
0FISCPER3 just have posting period and not year, so you will have to use varialbes for 0FISCYEAR separately.
Please let us know if it helps or if you are using some other variable based on 0FISCPER3 or 0FISCPER.
Regards,
Gaurav
Maybe you are looking for
-
I am trying to install CS 5.5 on a newer computer and every time I go through setup the serial number comes back good (green check mark, etc.) but then when I proceed with install, I am told to "please restart computer." No error number just "please
-
I have a wirless network. I connect all my computers to it and a printer. I can print wirelessly from all computers. I tried to add the printer to my new Macbook, which is connecte to the network, but can't find the printer on the add printer and sca
-
Hey there, I'm using an HP Pavilion DV6 laptop with a Windows 7 (64 bit) operating system. My graphics card is the AMD Radeon HD 6620G. I'm not entirely sure what my problem is with it, but it has been very consistent over the past few weeks, so I wi
-
Hai Experts, I am trying to create Purchase requisition using BAPI BAPI_PR_CREATE. I have passed Header, Item,Account data and corresponding Headerx.......structures to my BAPI and when i am running my Bapi it is throughing error....."Enter Cost Cent
-
Exporting files from my camcorder
I have a JVC GZ-HD7 and I can't get my files into quicktime to save my life!these are the steps I need http://software.transdigital.co.jp/products/cbsev/tutorialeng/index.html and I bought the Pro version but I have no idea how to get quicktime to ch