How to get missing year and months
hi,
I have to get count of each month of each year using SP
the parameters are date range , it can be
more than one year.
the problem is, in database there is data for few months only , but user can enter a big date range.
and i have show each month's count, if it does not exits then each month should show 0.
one approach was to get the count existing data for each year-month in a temp table, then loop through to insert missing year-month and finally select them.
second approach was to create temp table of year-month which is passed from parameter, buy subtracting two dates. then use left join to get the above result.
please suggest if there is any other way to accomplish the task?
yours sincerely
Can you show sample data + expected result?
SELECT COUNT(*) ,MONTH(dt) m, YEAR(dt) y FROM tbl
GROUP BY MONTH(dt), YEAR(dt)
but , I am only guessing, moreover , if you are using SQL Server 2008 and onwards take a look at grouping sets fetaure
SELECT custid, empid, YEAR(orderdate) AS orderyear, count(qty) AS qty
FROM dbo.Orders
GROUP BY GROUPING SETS
( custid ),
( empid ),
( YEAR(orderdate) )
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence
Similar Messages
-
How to display Current Year and Month in Drop Down list
Hi Dear friends,
I am devloping a report. It has got 2 pages--input and output(Report) page.
IN input page, user will select Month and Year from drop down list as one of the input parameters. (seperate drop down list 4 month and year)
Now, my problem is:
HOw to display current month and year by default in the dropdown list...........
I hope my question is clear.
Please help.
Regards,
AShNO da,
it is not working.
First i tired with for-loop. I initialized variable "i" to -2 (i=-2) I would get the year drop down list from 2003 but, by default 2003 would come.
So, i posted the question.
I tried your code. It is giving following error.
A Servlet Exception Has Occurred
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occured between lines: 122 and 127 in the jsp file: /test/inpt.jsp
Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\general\test\inpt$jsp.java:182: Invalid type expression.
first.set(Calendar.YEAR, 2003)
^
An error occured between lines: 127 and 131 in the jsp file: /test/inpt.jsp
Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\general\test\inpt$jsp.java:186: Invalid declaration.
out.write("\r\n \r\nYear : \r\n \r\n"); ^ An error occured between lines: 198 and 203 in the jsp file: /test/inpt.jsp Generated servlet error: C:\Program Files\Apache Tomcat 4.0\work\localhost\general\test\inpt$jsp.java:282: Invalid type expression. first1.set(Calendar.YEAR, 2003) ^ An error occured between lines: 203 and 207 in the jsp file: /test/inpt.jsp Generated servlet error: C:\Program Files\Apache Tomcat 4.0\work\localhost\general\test\inpt$jsp.java:286: Invalid declaration. out.write("\r\n \r\nYear :\r\n \r\n");
^
4 errors
Pls. Help.
Regards,
Ashu -
How to get Current day and month value in Stk applets
Friends please provide me the hint to get the Current Value of month and date from the Mobile equipment(ME).
please send feedback to [email protected]Use "PROVIDE LOCAL INFORMATION" command as per GSM 11.14. This however queries the handset date and time, and hence depends on the handset clock (which may not always be reliable).
-
Hi
I have created a report with two prompts, they are "Enter Start date:" and "Enter End date:" where i take date values from a calendar while prompting.
For example:
Start date = 10/11/2003
End date = 10/10/2003
If i want to display the End date means, i ll use UserResponse("Enter End Date:") in the webi reports. What should i do to calculate Year and Month from this user response value,
i used these calculations below, but it is not working, showing me #ERROR message.
1) ToDate(UserResponse("Enter End Date:");"dd/MM/yyyy") = #ERROR
2) FormatDate(ToDate(UserResponse("Enter End Date:");"dd/MM/yyyy");"dd/MM/yyyy") = #ERROR
3) Year(UserResponse("Enter End Date:") = The expression or sub-expression at position 6 in the 'Year' function uses an invalid data type. (WIS 10037)
4) FormatDate(ToDate(UserResponse("Enter End Date:");"dd/MM/yyyy hh:mm:ss A");"MM/dd/yyyy") =#ERROR
so help me how to get the year and month values from prompts ?
Thanks
Dineshkumarto get the Month Value and year value in Webi
month name
=Month(ToDate(UserResponse("Enter End Date:");""))
month number of the year
=MonthNumberOfYear(ToDate(UserResponse("Enter End Date:");""))
to get the Year Value
=Year(ToDate(UserResponse("Enter End Date:");""))
good luck -
Key Figure format in Years and Months..
Hi,
Is there any Key figure similar to 0SRVCLENKYF (Length of Service (in Years)) part of Headcount and Personnel Actions, which should give me value in Years and Months..?
Thanks in Advance,
Thanks,
Madhu.For curiousity sake...if you use the FIMA_DECIMAL_MONTHS_AND_YEARS Function Module, the output that you'll get is a months and years in fractional amounts. So, how are you going to get the Years and Months from this?
For example, if the from date is 20000101 and the to date is 20090914, the results from this Function Module will be Months = 116.42740 and Years = 9.70228. If you do use this, I'd suggest taking the whole number from passed value for years (9 in this example) and then calculate months by taking the franctional amount of the passed value for years and multiple it by 12 (0.70228 * 12), you end up with 9 Years, 8 Months (8.42736 to be exact, but you're going to want to truncate it to 8 so that when it goes above 8.5, the value doesn't become 9 when it still should be 8). -
Hi,
I'd like to get only year and month field. E.g. 201409.
Could you please let me know how to do it?
ddwrt:FormatDate(ddwrt:Today(),0804,1)
Thank you.Hi Denis - Can you use like:
formatted date "=TEXT(pickdate,"m") & "/" & YEAR(pickdate)"
http://weekbeforenext-blog.blogspot.in/2011/06/extracting-month-and-year-from-date-and.html
-prs -
How to Get the numeric equivalent of Year and Month with this format....
Hi Experts!
I just would like to know how to get the numeric equivalent of the Year and Month if the given format is like this....
31-May-07
where:
31 is the Day
May is the Month
07 is the Year
Is there a function in ABAP to do this? I wouldn't mind hardcoding for the Month, but what I'm after is the year.... they only gave me 2 digits for the year... and I would like to extract 4 digits from it... do ABAP still recognize it as '1907'? I think not...
Please help me on this experts and Thank you in Advance!!!
More Power!Hi Jayson,
You can require 2007 or 2017 or 2027..
or 1937 . or 1947 .. so on,
so just put a logic based on this. Just hard code as
lets say value is 31-May-07 (9 char field)
Case field+7(1).
WHEn 0.
concatenate '200' field+8(1) into year.
WHEN 1.
WHEN 2.
WHEN 3.
jsut code like this and check the syntaxes.
Reward points if useful.
Regards,
Atish -
the last few times I imported photos, the backup location was set to "documents" with no sub-folders. How do I get them into sub-folders - like year and month?
Use the Subfolder pulldown to set the subfolders:
-
When I look up the creation date for files on my Macbook (using "get info", or the information window in Iphoto) I get the date and month in brackets, but not the year. Why is this and how can I look up the year?
Does the Date Modified column in a window set to List view show the date correctly, or does it also display it incorrectly?
To add additional columns to a Finder (folder) window, with that window open and active open the View Options for it. You can do that by pressing Command-J or by selecting View Options from the View menu in the main menubar. -
Hi
How can I add 2 new metadata-fields to every photo in iPhoto ?
The new fields should state the age of my kids in years and months based on the date that they were born and the date that photo is taken.
Exampel:
My son is born 01.01.2010
My daughter is born 01.01.2012
Photo taken by data
Aage of son
Aage of daughter
01.07.2011
1 year 6 month
not born yet
01.01.2014
4 year 0 month
2 year 0 month
I would like to be able to search by kids age and get the info displayed when doing slideshows.
How to do this in iPhoto ?
Any alternatives to accomplish the same ?
Kind regardsIt can't be done with iPhoto. There are some DAM (digital asset management) applications that can write to other IPTC fields that iPhoto can't read. One such app is Media Pro 1.
However you would have to calculate the age for each date and add it to one of the fields. There are online age calculators that can do that for you: Age Calculators
If you go thru that much trouble then use iPhoto, make the calculations and add the age to the Description field. Then you can use Smart Albums to search for 1year 6 month text.
OT -
How to capture the presnt year and month .Urgent!!
Hi all,
I need to take the present year and month from the system and have to populate in drodownlists. can any one help me how to get these two seperatly and populate. xxxxxx (please read forum rules)
regards,
Sharan
Edited by: Armin Reichert on Jan 17, 2008 10:23 AMHi,
If you are using DropDownByKey UI elements:
1. Let's say the context attributes bound to the selectedKey property are called year and month respectively.
2. To populate year:
Date current = new Date(System.currentTimeMillis());
IWDAttributeInfo attinfo = wdContext.getNodeInfo().getAttribute(IContextElement.YEAR);
ISimpleTypeModifiable modinfo = attinfo.getModifiableSimpleType();
IModifiableSimpleValueSet valset = modinfo.getSVServices().getModifiableSimpleValueSet();
valset.put("currYear",String.valueOf(current.getYear));
3. You can do a similar thing for month.
Regards,
Satyajit. -
How to calculate year and month
Dear Friends
I have to make a customised report.In this report there are different buckets of one year from the year and month being entered by the user.
For example if user is giving input value for year and month as 200912 then system has to show data in first bucket for the period 200912 to 200901.In the second bucket system will show data for period 200812 to 200801.In this way system has to show data in 11 buckets for 11 years.
Is there any function module/BAPI in SAP through which system will calculate period of one year for different buckets for my report from the input value(year and month) being given by the user.
Moderator message - Please see The specified item was not found. before posting - post locked and Points unassigned
Edited by: Rob Burbank on Jan 5, 2010 11:03 AMHi Satish,
You can do this with a Standard function module.
I am providing my code below :
data : G_date type sy-datum.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
DATE = sy-datum " instead of sy-datum provide
" the select option here which user provides.
DAYS = C_fourty"45
MONTHS = C_MM "00
SIGNUM = C_Negative "'-'
YEARS = C_YY "00
IMPORTING
CALC_DATE = G_date. "G_date will have date less than 45 days
* " from the day program has been executed.
Now based upon the G_DATE, we can fetch remaining 10 buckets.
Regards,
Kittu
Edited by: Rob Burbank on Jan 5, 2010 11:01 AM -
Formula to go across years and months to find the value
Hello,
I am having difficulty writing a member formula where the rate is supposed to come from anyplace that's available prior to that month and year. This is for Re-forecasting purposes.
The example of how the concept should work is shown below. I have tried @priors, @shift, and @rangelastval. None of these calculations have been able to go through multiple years at the same time to get the rate from previous years and month. It works in the same year across the periods but not both periods and years.
Any idea what calculation function or a combination of calculation functions I can use so the calculated amount goes back as many years and months possible until it finds the rate.
Year
Periods
Rate
Amount
Calculated amount
FY15
Jan
0
100
0
FY15
Feb
0
100
0
FY15
Mar
0.4
100
40
FY15
Apr
0
100
40
FY15
May
0
100
40
FY15
Jun
0
100
40
FY15
Jul
0
100
40
FY15
Aug
0
100
40
FY15
Sep
0
100
40
FY15
Oct
0
100
40
FY15
Nov
0
100
40
FY15
Dec
0.3
100
30
FY16
Jan
0
100
30
FY16
Feb
0
100
30
FY16
Mar
0
100
30
FY16
Apr
0
100
30
FY16
May
0
100
30
FY16
Jun
0
100
30
FY16
Jul
0
100
30
FY16
Aug
0
100
30
FY16
Sep
0
100
30
FY16
Oct
0
100
30
FY16
Nov
0
100
30
FY16
Dec
0
100
30
FY17
Jan
0
100
30
FY17
Feb
0.5
100
50
FY17
Mar
0
100
50
FY17
Apr
0
100
50
FY17
May
0
100
50
FY17
Jun
0
100
50
FY17
Jul
0
100
50
FY17
Aug
0
100
50
FY17
Sep
0
100
50
FY17
Oct
0
100
50
FY17
Nov
0
100
50
FY17
Dec
0
100
50
FY18
Jan
0
100
50
FY18
Feb
0
100
50
FY18
Mar
0
100
50
FY18
Apr
0
100
50
FY18
May
0
100
50
FY18
Jun
0
100
50
FY18
Jul
0
100
50
FY18
Aug
0
100
50
FY18
Sep
0
100
50
FY18
Oct
0
100
50
FY18
Nov
0
100
50
FY18
Dec
0
100
50
FY19
Jan
0
100
50
FY19
Feb
0
100
50
FY19
Mar
0
100
50
FY19
Apr
0
100
50
FY19
May
0
100
50
FY19
Jun
0
100
50
FY19
Jul
0
100
50
FY19
Aug
0
100
50
FY19
Sep
0
100
50
FY19
Oct
0
100
50
FY19
Nov
0
100
50
FY19
Dec
0
100
50
FY20
Jan
0
100
50
FY20
Feb
0
100
50
FY20
Mar
0
100
50
FY20
Apr
0
100
50
FY20
May
0
100
50
FY20
Jun
0
100
50
FY20
Jul
0
100
50
FY20
Aug
0
100
50
FY20
Sep
0
100
50
FY20
Oct
0
100
50
FY20
Nov
0
100
50
FY20
Dec
0
100
50
FY21
Jan
0
100
50
FY21
Feb
0
100
50
FY21
Mar
0
100
50
FY21
Apr
0
100
50
FY21
May
0
100
50
FY21
Jun
0
100
50
FY21
Jul
0
100
50
FY21
Aug
0
100
50
FY21
Sep
0
100
50
FY21
Oct
0
100
50
FY21
Nov
0
100
50
FY21
Dec
0
100
50
Thanks in advance!ELSE
IF (@PRIORS(SKIPMISSING, RATE) == #Missing)
IF (@ISMBR(&FcstYear7))
"Amount"=Amount*@PRIORS(SKIPMISSING,"Rate",(&FcstStartMo:"Dec"->&FcstYear1, "Jan":"Dec"->&FcstYear2,"Jan":"Dec"->&FcstYear3,"Jan":"Dec"->&FcstYear4,"Jan":"Dec"->&FcstYear5,"Jan":"Dec"->&FcstYear6)));
similarly repeated for the years 6,5,4,3,2 but it gave the following error "Error: 1200400 Error executing formula for [Check_1] (line 9): scalar double argument expected in function [@_UMINUS]"
How can I use XRANGE in this because the function has the following limitation?
@XRANGE can be used only in these functions: @AVGRANGE, @SUMRANGE, @MINRANGE, @MINSRANGE, @MAXRANGE, @MAXSRANGE, @STDDEVRANGE, @MOVSUM, @MOVAVG, @MOVMIN, @MOVMAX, @MOVMED, @SPLINE. -
How to Get Missing Dates for Each Support Ticket In My Query?
Hello -
I'm really baffled as to how to get missing dates for each support ticket in my query. I did a search for this and found several CTE's however they only provide ways to find missing dates in a date table rather than missing dates for another column
in a table. Let me explain a bit further here -
I have a query which has a list of support tickets for the month of January. Each support ticket is supposed to be updated daily by a support rep, however that isn't happening so the business wants to know for each ticket which dates have NOT been
updated. So, for example, I might have support ticket 44BS which was updated on 2014-01-01, 2014-01-05, 2014-01-07. Each time the ticket is updated a new row is inserted into the table. I need a query which will return the missing dates per
each support ticket.
I should also add that I DO NOT have any sort of admin nor write permissions to the database...none at all. My team has tried and they won't give 'em. So proposing a function or storable solution will not work. I'm stuck with doing everything
in a query.
I'll try and provide some sample data as an example -
CREATE TABLE #Tickets
TicketNo VARCHAR(4)
,DateUpdated DATE
INSERT INTO #Tickets VALUES ('44BS', '2014-01-01')
INSERT INTO #Tickets VALUES ('44BS', '2014-01-05')
INSERT INTO #Tickets VALUES ('44BS', '2014-01-07')
INSERT INTO #Tickets VALUES ('32VT', '2014-01-03')
INSERT INTO #Tickets VALUES ('32VT', '2014-01-09')
INSERT INTO #Tickets VALUES ('32VT', '2014-01-11')
So for ticket 44BS, I need to return the missing dates between January 1st and January 5th, again between January 5th and January 7th. A set-based solution would be best.
I'm sure this is easier than i'm making it. However, after playing around for a couple of hours my head hurts and I need sleep. If anyone can help, you'd be a job-saver :)
Thanks!!CREATE TABLE #Tickets (
TicketNo VARCHAR(4)
,DateUpdated DATETIME
GO
INSERT INTO #Tickets
VALUES (
'44BS'
,'2014-01-01'
INSERT INTO #Tickets
VALUES (
'44BS'
,'2014-01-05'
INSERT INTO #Tickets
VALUES (
'44BS'
,'2014-01-07'
INSERT INTO #Tickets
VALUES (
'32VT'
,'2014-01-03'
INSERT INTO #Tickets
VALUES (
'32VT'
,'2014-01-09'
INSERT INTO #Tickets
VALUES (
'32VT'
,'2014-01-11'
GO
GO
SELECT *
FROM #Tickets
GO
GO
CREATE TABLE #tempDist (
NRow INT
,TicketNo VARCHAR(4)
,MinDate DATETIME
,MaxDate DATETIME
GO
CREATE TABLE #tempUnUserdDate (
TicketNo VARCHAR(4)
,MissDate DATETIME
GO
INSERT INTO #tempDist
SELECT Row_Number() OVER (
ORDER BY TicketNo
) AS NROw
,TicketNo
,Min(DateUpdated) AS MinDate
,MAx(DateUpdated) AS MaxDate
FROM #Tickets
GROUP BY TicketNo
SELECT *
FROM #tempDist
GO
-- Get the number of rows in the looping table
DECLARE @RowCount INT
SET @RowCount = (
SELECT COUNT(TicketNo)
FROM #tempDist
-- Declare an iterator
DECLARE @I INT
-- Initialize the iterator
SET @I = 1
-- Loop through the rows of a table @myTable
WHILE (@I <= @RowCount)
BEGIN
-- Declare variables to hold the data which we get after looping each record
DECLARE @MyDate DATETIME
DECLARE @TicketNo VARCHAR(50)
,@MinDate DATETIME
,@MaxDate DATETIME
-- Get the data from table and set to variables
SELECT @TicketNo = TicketNo
,@MinDate = MinDate
,@MaxDate = MaxDate
FROM #tempDist
WHERE NRow = @I
SET @MyDate = @MinDate
WHILE @MaxDate > @MyDate
BEGIN
IF NOT EXISTS (
SELECT *
FROM #Tickets
WHERE TicketNo = @TicketNo
AND DateUpdated = @MyDate
BEGIN
INSERT INTO #tempUnUserdDate
VALUES (
@TicketNo
,@MyDate
END
SET @MyDate = dateadd(d, 1, @MyDate)
END
SET @I = @I + 1
END
GO
SELECT *
FROM #tempUnUserdDate
GO
GO
DROP TABLE #tickets
GO
DROP TABLE #tempDist
GO
DROP TABLE #tempUnUserdDate
Thanks,
Shridhar J Joshi
<If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'> -
T:inputCalendar year and month only
Hej there,
I'd like to use t:inputCalendar to allow the user only to choose a certain year and month, so not including the day.
I'm not sure if it's possible at all, but I started out using this:
<t:inputCalendar renderAsPopup="true" popupSelectMode="month" popupDateFormat="MM" />
So now the user has a button, but when s/he clicks on it, the full calendar is shown, including the days.
How do I get rid of that?
Thanks,
DavidWhen you are not really using date, you might as well think of a different solution altogether.
Probably you can have two separate drop-down lists for selecting the month and the year.
DavidTarr wrote:
Hej there,
I'd like to use t:inputCalendar to allow the user only to choose a certain year and month, so not including the day.
I'm not sure if it's possible at all, but I started out using this:It is possible to convert the pattern using convertDateTime. But this only converts the text field display.
<f:convertDateTime type="date" pattern="MM-yy"/>
<t:inputCalendar renderAsPopup="true" popupSelectMode="month" popupDateFormat="MM" />
So now the user has a button, but when s/he clicks on it, the full calendar is shown, including the days.
How do I get rid of that?I am not sure if you can get rid of that. Obviously, no body would expect to see a calendar without dates. It does not make much sense.
>
Thanks,
David
Maybe you are looking for
-
Mail says my Home folder is full?
Strange, Mail keeps telling me it can't save changes (i.e. do anything) because my Home folder is full and that I should move documents? What's the deal? I have no documents in the documents folder in Home... Any ideas?
-
Is the os x Mavericks can be installed for my macbook pro (intel core 2 duo, 2.66 GHz, 4 GB ram?) ?
-
Panasonic PV-GS320: worth the extra $?
Any thoughts on this camcorder? Does it have analog in to convert old 8mm to miniDV? Thanks!
-
Pdf attachment no iBooks "Open As"
User has an iPad Air 2 running iOS 8.2 and has received a pdf as an attachment. He goes to "Open As" to open and save the pdf in iBooks but iBooks is not in the listing. Looking in the "More" shows a total of 3 items not 10, and iBooks is not listed
-
BEA WLS 9.0 java.lang.NoClassDefFoundError: utils/ImportPrivateKey
Hi I'm newbie on this forum and on BEA WebLogic 9.0. I have to import my certificate in the keystore in order to setup SSL connection. I'm trying to use the java utils provided by BEA WL, but I have this error: bash-3.00# java utils.ImportPrivateKey