Insert Month and Year
Table ( In-focus)
CREATE TABLE "LIBRARY"."INFOCUS_LOG"
("LOGDATETIME" DATE,
"COUNTER" NUMBER(6,0)
Procedure
create or replace PROCEDURE IN_FOCUS_PAGE
(ldt INFOCUS_LOG.logdatetime%TYPE,
COT INFOCUS_LOG.counter%TYPE)
IS
BEGIN
INSERT
INTO INFOCUS_LOG
VALUES(ldt, COT);
DBMS_OUTPUT.PUT_LINE('RECORD IS ADDED......!');
COMMIT;
END IN_FOCUS_PAGE;
What do I need to do if I want to insert month and year only for this particular table.
Result Example:
JAN-2007
FEB-2007
MAR-2007
Message was edited by:
user579538
A DATE is always going to have a full day and time component, so you cannot store just the month and year. You can, of course, choose to display just the month and year, i.e.
SELECT TO_CHAR( date_column, 'MON-YYYY' )
FROM some_tableor to extract the month and year separately
SELECT EXTRACT( year from date_column ) yr,
EXTRACT( month from date_column ) dt
FROM some_tableJustin
Similar Messages
-
Problem to insert only month and year instead of full date
select b.penjara_id, p.penj_lokasi, a.no_daftar, b.episod, b.nama1,to_char(a.trkh_mula_prl,'dd/mm/yyyy') as trkh_mula_prl, to_char(bulan_proses,'mm/yyyy') as bulan_proses,
b.epd, b.lpd
from prl_daftar_proses a, senarai_pesalah b, penjara p
where a.no_daftar=b.no_daftar
and a.episod=b.episod
and b.penjara_id = p.penjara_id
and a.setuju_jplp is null
and a.bulan_proses between to_date(:FROM,'dd/mm/yyyy') and to_date(:TO,'dd/mm/yyyy')
order by b.penjara_id, a.bulan_proses,a.no_daftarHi,anyone can help me how i can insert only month and year from the value that have full date in the database??
for example,the date is 09/18/2012, but i just want to insert 09/2012 as parameter. If i want to insert only one parameter, i can do that..But i have problem when I want to insert two parameters..jeneesh wrote:
Welcome to the forum..
This..?
Assuming bulan_proses is a date without time part
select b.penjara_id, p.penj_lokasi, a.no_daftar, b.episod, b.nama1,to_char(a.trkh_mula_prl,'dd/mm/yyyy') as trkh_mula_prl, to_char(bulan_proses,'mm/yyyy') as bulan_proses,
b.epd, b.lpd
from prl_daftar_proses a, senarai_pesalah b, penjara p
where a.no_daftar=b.no_daftar
and a.episod=b.episod
and b.penjara_id = p.penjara_id
and a.setuju_jplp is null
and a.bulan_proses between to_date(:FROM,'mm/yyyy') and last_day(to_date(:TO,'mm/yyyy'))
order by b.penjara_id, a.bulan_proses,a.no_daftar
i got another problem..
before that.may i know what is the function of last_day? -
When my delegates are filling in a event form i have put together, a large number of them forget to change either the month or year on the date field. Is there a way to have a date field that has drop down boxes for day, month and year so they have to choose rather than a date been already on the screen??
ThanksHi Christopher,
The WEEKDAY function allows specifying either Sunday or Monday as the first day of the week:
WEEKDAY
The WEEKDAY function returns a number that is the day of the week for a given date. WEEKDAY(date, first-day)
 date: The date the function should use. date is a date/time value. The time portion is ignored by this function.
 first-day: An optional value that specifies how days are numbered.
Sunday is 1 (1 or omitted): Sunday is the first day (day 1) of the week and Saturday is day 7.
Monday is 1 (2): Monday is the first day (day 1) of the week and Sunday is day 7. Monday is 0 (3): Monday is the first day (day 0) of the week and Sunday is day 6.
But I think you are referring to the first day of the 'workweek', for which I do not see a means of defining a custom value.
Since you want to 'insert categories', though, you could easily define your own, using WEEKDAY(date) or WEEKDAY(date,1), plus an IF statement to return the category label appropriate to the day. Here's one for a Sunday to Thursday work week. Dates are in column A, the formula is in whichever column you want as the Category column. For the example, I've placed it in column B.
B2, and filled down: =IF(WEEKDAY(A)<6,"Work","Off")
The top table shows the weekday numbers returned for each day of the week for each of the three permitted values for the optional second argument. The bottom table shows the results from the formula above, used to define a category label for each date:
A10 was left blank intentionally, to determine if the lack of data resulted in an error. The Warning message, flagged by the blue 'warning' triangle, is "The formula uses a number in place of a date." The 'date' assigned to this numerical value of zero was a Friday, but I'm not certain when. Probably best to avoid extra rows with no date shown.
Regards,
Barry -
Selecting records based on month and year parameters
Hi. I have a sql 2008 r2 stored procedure which needs modifying to return the data based on a start / end month and year.
It's a large SP so I'll summarise - It accepts four parameters:
@StartMonth NVARCHAR(10)
@StartYear NVARCHAR(4)
@EndMonth NVARCHAR(10)
@EndYear NVARCHAR(4)
The current WHERE clause is:
WHERE ta.TimeByDay BETWEEN '01' + '-' + ltrim(LEFT(@StartMonth, 3)) + '-' + @StartYear
AND convert(nvarchar,datediff(day, ta.TimeByDay, dateadd(month, 1, ta.TimeByDay))) + '-' + ltrim(LEFT(@EndMonth, 3)) + '-' + @EndYear
Example of input parameters:
@StartMonth = N'January',
@StartYear = N'2014',
@EndMonth = N'February',
@EndYear = N'2014',
Result:
The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.
(1 row(s) affected)
However it executes correctly if we do either of the following:
1) Run the SQL direct in QA and type in January and February rather than passing in the Start/End Month parameters
2) As you can see we use the following datediff call to get the number of days per month. IF I replace this with '28', or '31' for example the query also runs (oddly number 1 above then also runs by executing the SP):
convert(nvarchar,datediff(day, ta.TimeByDay, dateadd(month, 1, ta.TimeByDay)))
How do I update the WHERE clause to return records between a start/end month and year?
I'm a day on this so any help appreciated.
Thankscreate function NthDayOfMonth (@year int, @month smallint, @weekday varchar(15), @nth smallint)
returns datetime
as
begin
declare @the_date datetime, @c_date datetime, @cth smallint
set @cth = 0
set @c_date = convert(varchar,@year)+'-'+convert(varchar,@month)+'-01'
while month(@c_date) = @month
begin
if datename(weekday,@c_date) = @weekday set @cth = @cth + 1
if @cth = @nth and datename(weekday,@c_date) = @weekday set @the_date = @c_date
set @c_date = dateadd(day,1,@c_date)
end
return @the_date
end
go
create function Dates(@date datetime)
returns @table table
now datetime,
today datetime,
Month_start datetime,
Month_end datetime,
Prev_Month_Start datetime,
Prev_Month_End datetime,
Week_Start datetime,
Week_End datetime,
Prev_Week_Start datetime,
Prev_Week_End datetime,
Quarter_Start datetime,
Quarter_End datetime,
Prev_Quarter_Start datetime,
Prev_Quarter_End datetime,
Year_Start datetime,
Year_End datetime,
Prev_Year_Start datetime,
Prev_Year_End datetime,
Month_End_TS datetime,
Prev_Month_End_TS datetime,
Week_End_TS datetime,
Prev_Week_End_TS datetime,
Quarter_End_TS datetime,
Prev_Quarter_End_TS datetime,
Year_End_TS datetime,
Prev_Year_End_TS datetime,
Year smallint,
Month smallint,
Day smallint,
Month_Name varchar(15),
Day_Name varchar(15),
WD smallint
as
begin
if @date IS NULL set @date = getdate()
insert into @table
select
@date as now,
convert(datetime,convert(varchar,@date,101)) as today,
dateadd(day,0-day(@date)+1,convert(datetime,convert(varchar,@date,101))) as Month_Start,
dateadd(day,-1,dateadd(month,1,dateadd(day,0-day(@date)+1,convert(datetime,convert(varchar,@date,101))))) as Month_end,
dateadd(month,-1,dateadd(day,0-day(@date)+1,convert(datetime,convert(varchar,@date,101)))) as Prev_Month_start,
dateadd(day,-1-day(@date)+1,convert(datetime,convert(varchar,@date,101))) as Prev_Month_End,
dateadd(day,1-datepart(dw,@date),convert(datetime,convert(varchar,@date,101))) as Week_Start,
dateadd(day,7-datepart(dw,@date),convert(datetime,convert(varchar,@date,101))) as Week_End,
dateadd(day,-6-datepart(dw,@date),convert(datetime,convert(varchar,@date,101))) as Prev_Week_Start,
dateadd(day,0-datepart(dw,@date),convert(datetime,convert(varchar,@date,101))) as Prev_Week_End,
convert(datetime,convert(varchar,year(@date)) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,@date)-1)*3)+1),2)+'-01') as quarter_start,
dateadd(day,-1,dateadd(quarter,1,convert(datetime,convert(varchar,year(@date)) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,@date)-1)*3)+1),2)+'-01'))) as quarter_end,
convert(datetime,convert(varchar,year(dateadd(quarter,-1,@date))) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,dateadd(quarter,-1,@date))-1)*3)+1),2)+'-01') as prev_quarter_start,
dateadd(day,-1,dateadd(quarter,1,convert(datetime,convert(varchar,year(dateadd(quarter,-1,@date))) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,dateadd(quarter,-1,@date))-1)*3)+1),2)+'-01'))) as prev_quarter_end,
dateadd(day,1-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101))) as Year_Start,
dateadd(year,1,dateadd(day,0-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101)))) as Year_End,
dateadd(year,-1,dateadd(day,1-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101)))) as Prev_Year_Start,
dateadd(year,-1,dateadd(year,1,dateadd(day,0-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101))))) as Prev_Year_End,
dateadd(ms,-3,dateadd(day,0,dateadd(month,1,dateadd(day,0-day(@date)+1,convert(datetime,convert(varchar,@date,101)))))) as Month_End_Ts,
dateadd(ms,-3,dateadd(day,-1-day(@date)+2,convert(datetime,convert(varchar,@date,101)))) as Prev_Month_End_TS,
dateadd(ms,-3,dateadd(day,8-datepart(dw,@date),convert(datetime,convert(varchar,@date,101)))) as Week_End_TS,
dateadd(ms,-3,dateadd(day,1-datepart(dw,@date),convert(datetime,convert(varchar,@date,101)))) as Prev_Week_End_TS,
dateadd(ms,-3,dateadd(day,0,dateadd(quarter,1,convert(datetime,convert(varchar,year(@date)) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,@date)-1)*3)+1),2)+'-01')))) as quarter_end_TS,
dateadd(ms,-3,dateadd(day,0,dateadd(quarter,1,convert(datetime,convert(varchar,year(dateadd(quarter,-1,@date))) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,dateadd(quarter,-1,@date))-1)*3)+1),2)+'-01')))) as prev_quarter_end_TS,
dateadd(ms,-3,dateadd(year,1,dateadd(day,1-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101))))) as Year_End_TS,
dateadd(ms,-3,dateadd(day,1-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101)))) as Prev_Year_End_TS,
Year(@date) as Year,
Month(@date) as Month,
Day(@Date) as Day,
datename(month,@Date) as Month_Name,
datename(WEEKDAY,@date) as Day_Name,
datepart(weekday,@date) as WD
return
end
go
create function Holidays(@year smallint)
returns @table table
date datetime,
type varchar(10),
name varchar(25)
as
begin
insert into @table
select convert(datetime,convert(varchar,@year)+'-01-01') as date,'Holiday' as type ,'New Years Day' as name UNION ALL
select dbo.NthDayOfMonth(@year,2, 'Monday',3),'Holiday','Family Day' UNION ALL
select dateadd(d,0-case when datepart(weekday,convert(varchar,@year)+'-05-25') in (1,2) then 5+datepart(weekday,convert(varchar,@year)+'-05-25') else datepart(weekday,convert(varchar,@year)+'-05-25')-1 end, convert(varchar,@year)+'-05-25') ,'Holiday','Victoria Day' UNION ALL
select convert(varchar,@year)+'-01-07' ,'Holiday','Canada Day' UNION ALL
select dbo.NthDayOfMonth(@year,8, 'Monday',1),'Holiday','Civic Holiday' UNION ALL
select dbo.NthDayOfMonth(@year,9, 'Monday',1),'Holiday','Labour Day' UNION ALL
select dbo.NthDayofMonth(@year,10,'Monday',2),'Holiday','Thanksgiving' UNION ALL
select convert(varchar,@year)+'-11-11' ,'Holiday','Rememberance Day'UNION ALL
select convert(varchar,@year)+'-12-25' ,'Holiday','Christmas Day' UNION ALL
select convert(varchar,@year)+'-12-26' ,'Holiday','Boxing Day'
update @table
set date =
case when name != 'Boxing Day' and datepart(weekday,date) = 7 then dateadd(day,2,date)
when name != 'Boxing Day' and datepart(weekday,date) = 1 then dateadd(day,1,date)
when name = 'Boxing Day' and datepart(weekday,date) = 7 then dateadd(day,2,date)
when name = 'Boxing Day' and datepart(weekday,date) = 1 then dateadd(day,2,date)
when name = 'Boxing Day' and datepart(weekday,date) = 2 then dateadd(day,1,date)
else date
end
return
end
go
Using these functions (in place of a calendar table) you could do something like this:
DECLARE @forumTable TABLE (sales MONEY, saleDate DATE)
INSERT INTO @forumTable (sales, saleDate)
VALUES
(123.45, '2014-01-05'),(678.90, '2014-01-06'),(111.21, '2014-01-07'),(314.15, '2014-01-08'),(161.71, '2014-01-09'),
(819.20, '2014-02-05'),(212.22, '2014-02-06'),(324.25, '2014-02-07'),(262.72, '2014-02-08'),(829.30, '2014-02-09')
SELECT SUM(f.sales), d.month_end
FROM @forumTable f
CROSS APPLY sandbox.dbo.dates(f.saleDate) d
GROUP BY d.month_end -
Hi all Thanks in Advance
I need help in Pivoting Data
SELECT ID,MONTH,COUNT FROM TABLE_PIVOT ORDER BY ID,MONTH
ID MONTH COUNT
10 10/01/2009 60
10 11/01/2009 80
10 12/01/2009 78
10 01/01/2010 81
10 02/01/2010 73
10 03/01/2010 84
10 04/01/2010 100
10 05/01/2010 107
10 06/01/2010 90
10 07/01/2010 0
10 08/01/2010 0
10 09/01/2010 73
20 10/01/2010 71
20 11/01/2010 76
20 12/01/2010 79
20 01/01/2011 79
20 02/01/2011 81
20 03/01/2011 88
20 04/01/2011 97
20 05/01/2011 87
20 06/01/2011 97I tried to pivot with below query
SELECT ID,
SUM(DECODE(to_char(month,'MM'),'01',count,0)) " Jan",
SUM(DECODE(to_char(month,'MMYY'),'02',count,0)) Feb,
SUM(DECODE(to_char(month,'MM'),'03',count,0)) Mar,
SUM(DECODE(to_char(month,'MM'),'04',count,0)) Apr,
SUM(DECODE(to_char(month,'MM'),'05',count,0)) May,
SUM(DECODE(to_char(month,'MM'),'06',count,0)) June,
SUM(DECODE(to_char(month,'MM'),'07',count,0)) July,
SUM(DECODE(to_char(month,'MM'),'08',count,0)) August,
SUM(DECODE(to_char(month,'MM'),'09',count,0)) September,
SUM(DECODE(to_char(month,'MM'),'10',count,0)) October,
SUM(DECODE(to_char(month,'MM'),'11',count,0)) November,
SUM(DECODE(to_char(MONTH,'MM'),'12',count,0)) December
FROM Table_PIVOT
GROUP BY ID
ORDER BY ID
ID Jan FEB MAR APR MAY JUNE JULY AUGUST SEPTEMBER OCTOBER NOVEMBER DECEMBER
10 81 0 84 100 107 90 0 0 73 60 80 78
20 79 0 88 97 87 97 0 0 0 71 76 79I want output to display the column names with Month and Year like below
ID Oct-2009 Nov-2009 Dec-2009 Jan-2010 Feb-2010 ................... OCT-2010 NOV-2010 DEC-2010 JAN-2011 FEB-2011 ......
10 60 80 78 81 73 ...................
20 71 76 79 79 81
CREATE TABLE "TABLE_PIVOT"
( "ID" NUMBER,
"MONTH" DATE,
"COUNT" NUMBER
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('10/01/2009','MM/DD/YYYY'),60);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('11/01/2009','MM/DD/YYYY'),80);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('12/01/2009','MM/DD/YYYY'),78);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('01/01/2010','MM/DD/YYYY'),81);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('02/01/2010','MM/DD/YYYY'),73);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('03/01/2010','MM/DD/YYYY'),84);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('04/01/2010','MM/DD/YYYY'),100);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('05/01/2010','MM/DD/YYYY'),107);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('06/01/2010','MM/DD/YYYY'),90);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('07/01/2010','MM/DD/YYYY'),0);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('08/01/2010','MM/DD/YYYY'),0);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (10,to_timestamp('09/01/2010','MM/DD/YYYY'),73);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('10/01/2010','MM/DD/YYYY'),71);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('11/01/2010','MM/DD/YYYY'),76);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('12/01/2010','MM/DD/YYYY'),79);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('01/01/2011','MM/DD/YYYY'),79);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('02/01/2011','MM/DD/YYYY'),81);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('03/01/2011','MM/DD/YYYY'),88);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('04/01/2011','MM/DD/YYYY'),97);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('05/01/2011','MM/DD/YYYY'),87);
Insert into TABLE_PIVOT (ID,MONTH,COUNT) values (20,to_timestamp('06/01/2011','MM/DD/YYYY'),97);
COMMIT;Hi,
user1849 wrote:
Any Sample code is appreciated
I didn't see any solution for following one in your linklI think Centinul was specifically referring to:
Help for a query to add columns
but other links from
SQL and PL/SQL FAQ
may help you more.
>
Re: How to pipeline a function with a dynamic number of columns?
Posted: May 9, 2006 2:58 PM in response to: Billy Verreynne Reply
Interesting stuff! It's going to take me awhile to digest it.
For what it's worth, I was trying to build a pivoting function that would take a MYTABLE table like this:
YEAR CITY X Y
2000 BAL 95 96
2000 BOS 101 101
2001 BAL 92 94
2001 BOS 101 101
2002 BAL 98 98
2002 BOS 98 99
2003 BAL 95 96
2003 BOS 105 104
and allow me to do something like:
CREATE VIEW MYPIVOT
AS
SELECT *
FROM TABLE (PIVOT(MYTABLE, [with other params]))
and get the following view MYPIVOT on the table:
YEAR BOS_X BOS_Y BAL_X BAL_Y
2000 101 101 95 96
2001 101 101 92 94
2002 98 99 98 98
2003 105 104 95 96
Where the number of distinct CITY values will vary over time. I am able to build the query I need dynamically, but since the CITY data values in the original table change, the columns are not necessarily static from invocation to invocation. Therefore I didn't want to just create a view using the dynamic SQL once, because it may need to be created next time I need to access the view. I wanted to be able to access the pivoted data on demand.A pipelined function is your best bet for that.
I couldn't do was be able to execute the query and treat it as a pipelined function, hence my original question.Sorry, I don't understand.
I'll dig into the code above to see if it does what I wanted, but if someone has a better suggestion on how to approach this, I'd be interested in hearing it.A completely different approach is String Aggregation , where you would get output like this:
YEAR TXT
BOS_X BOS_Y BAL_X BAL_Y
2000 101 101 95 96
2001 101 101 92 94
2002 98 99 98 98
2003 105 104 95 96Note that this output contains 6 rows and 2 columns. On the first row, year is NULL and txt=' BOS_X BOS_Y BAL_X BAL_Y'. You can do this is pure, static SQL, without knowing the number of cities in advance. -
Loop through month and year till date while using a merge statement
Hello Guys,
I have 2 tables with the following datas in them:-
Company
CompanyId CompanyName
1 Company1
2 Company2
3 Company3
Employees
EmployeeId EmployeeName CompanyId StartDate
1 Employee1 1 12/21/2011
2 Employee2 1 01/20/2012
3 Employee3 2 03/23/2012
4 Employee4 2 07/15/2012
5 Employee5 2 01/20/2013
6 Employee6 3 12/17/2013
Now i want to check, How many people were recruited in the team in the specified month and year? I have the storage table as follows:-
RecruiterIndicator
CompanyId Year Month EmployeeRecruited
1 2011 12 1
1 2012 1 1
2 2012 3 1
2 2012 7 1
2 2013 1 1
3 2013 12 1
This should be a merge stored procedure that should update the data if it is present for the same month year and company and insert if that is not present?
Please help me with this
Thanks
AbhishekIt's not really clear where the merge to come into play. To get the RecruiterIndicator table from Employess, this query should do:
SELECT CompanyId, Year(StartDate), Month(StartDate), COUNT(*)
FROM Employees
GROUP BY CompanyId, Year(StartDate), Month(StartDate)
Erland Sommarskog, SQL Server MVP, [email protected] -
Query to get holidays including saturday and sunday by giving month and year as input
query to get holidays including saturday and sunday by giving month and year as input.
Hi,
Create a table for holidays. You could INSERT one row for each holiday in each year, but it might be more useful if you just create 1 row for every day, with a column that tells whether that day is a holday, part of a weekend, or a work day.
See
http://forums.oracle.com/forums/message.jspa?messageID=3351081
for a user-defined function that tests if a given DATE is holiday.
You could use such a function when populating the table I mentioned earlier. -
Dynamic filter by Country, month and year
Hi,
I have a file extracted from SAP BI and incrusted in xls format in Xcelsius.
I have to filter data by Country, year, and month. I´ve seen the blog of Ingo Hilgefort 'Creating an Xcelsius dashboard on top of SAP BI that has a similar expanation of what I need to do.
Unfortunatelly, the problem I ´m facing is how to organize the data including the months in the spreadsheet incrusted in the Xcelsius.
What I have at the moment in the spreadsheet is a column with countries (9), an one column by KPI (10). Beside the last column I have the inserted data column for the countries so in the dashboard I can pick a country and shows me the KPI´s by country. What I still don´t found is how to make the selection also by month and year.
If anyone could help, I would be grateful.
Thanks in advance,
DiegoCharles,
It seems to be what i´m looking for. It is perfect to see the KPI´s by country and month in a year.
But with that spreadcheet i still cannot choose only the KPI´S year values by countries (independently of the month).
Another question I would like to make to you (as i told you i´m making my first steps in Xcelsius) is if you write the formula =BUSCARV($C$7;$C$17:$G$23;5;FALSO) manually into the excel.
Thanks in advance,
Diego -
I want to keep date special month and year.
I want to keep date special month and year.
Example in sqlplus
insert into area(input_time) values(to_date('MAR-04','MON-YY'));
and select
select input_time from area;
the result
01 MAR 2004
in Oracle
01-MAR-2004 12:00:00 AM
I don't keep day, but I want to keep month and year.
Can you do?
Thanks.An Oracle date column must contain a date down to the second. If you don't specify a day or a time, it will default to the first of the month and midnight.
If you want a column to only contain values at the beginning of a particular month, you can create a CHECK constraint that verifies that
input_time = trunc( input_time, 'MM' )Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
How i can get list of months and years from my tables(ex. tab1), when i have start date ex. 072003 and end date ex. 042005 . That i use in report 6i.. . .
months | years| . . . . .
----------------------------------If i am not wrong you want these result
SQL> SELECT hiredate FROM emp;
HIREDATE
17-DEC-80
20-FEB-81
22-FEB-81
02-APR-81
28-SEP-81
01-MAY-81
09-JUN-81
19-APR-87
17-NOV-81
08-SEP-81
23-MAY-87
03-DEC-81
03-DEC-81
23-JAN-82
14 rows selected.
SQL> INSERT INTO emp (empno,hiredate,deptno) VALUES (1,SYSDATE,10);
1 row created.
SQL> COMMIT;
Commit complete.
SQL> SELECT hiredate FROM emp;
HIREDATE
17-DEC-80
20-FEB-81
22-FEB-81
02-APR-81
28-SEP-81
01-MAY-81
09-JUN-81
19-APR-87
17-NOV-81
08-SEP-81
23-MAY-87
03-DEC-81
03-DEC-81
23-JAN-82
01-SEP-06
15 rows selected.
SQL> SELECT TO_CHAR(a,'MON-YYYY') b FROM
2 (SELECT ADD_MONTHS(TRUNC(sysdate,'YYYY'),(rn.r-1)) a FROM
3 (SELECT ROWNUM r FROM user_objects WHERE ROWNUM<=12) rn)
4 MINUS
5 SELECT TO_CHAR(hiredate,'MON-YYYY') FROM emp;
B
APR-2006
AUG-2006
DEC-2006
FEB-2006
JAN-2006
JUL-2006
JUN-2006
MAR-2006
MAY-2006
NOV-2006
OCT-2006
11 rows selected.
SQL> SELECT b FROM
2 (SELECT TO_CHAR(a,'MON-YYYY') b FROM
3 (SELECT ADD_MONTHS(TRUNC(sysdate,'YYYY'),(rn.r-1)) a FROM
4 (SELECT ROWNUM r FROM user_objects WHERE ROWNUM<=12) rn)
5 MINUS
6 SELECT TO_CHAR(hiredate,'MON-YYYY') FROM emp)
7 WHERE b BETWEEN 'NOV-2006' AND 'SEP-2006';
B
NOV-2006
OCT-2006
SQL> Khurram -
Needing a multi-month and year-in-view option for ical!
Hello all!
I could really use a multi-month and year-in-view format in ical... I've seen some dated posts - is anyone aware of any new developments/options for this?
thanks and peace-
DWI turn off all calendars but the birthdays. Select [Print]. Choose all the months you want to see. Deselect all calendars but birthdays. Click [Continue]. On the next menu, go to "Layout", select how many pages to print on the paper. I usually print a border around each calendar then you're good to go!
By only printing the birthdays calenar, you won't get too many appointments to get in the way of brain storming and future planning, yet the computer still thinks its printing a useful calendar. -
How to get Week,Month and Year details from a date column
Hi frenz,
I've a column like tran_date which is a date column..... I need the next week details based on this column and so on...
I need month and year details as well based on this tran_date column.... can any one tell me how...
Thanks in advanceMy example for objects:
create or replace type date_object as object
centure number,
year number,
month number,
day number,
hour number,
minute number,
second number,
daypart number,
week number,
constructor function date_object(p_dt date)
return SELF as result
create or replace type body date_object is
constructor function date_object(p_dt date)
return SELF as result
as
begin
SELF.centure:= trunc(to_char(p_dt,'YYYY')/100);
SELF.year:= to_char(p_dt,'YYYY');
SELF.month:= to_char(p_dt,'MM');
SELF.day:= to_char(p_dt,'DD');
SELF.hour:= to_char(p_dt,'HH24');
SELF.minute:= to_char(p_dt,'MI');
SELF.second:= to_char(p_dt,'SS');
SELF.daypart:= p_dt-trunc(p_dt,'DD');
SELF.week:= to_char(p_dt,'IW');
return;
end;
end;
select date_object(sysdate),
date_object(sysdate).year
from dual;Regards,
Sayan M. -
Sales report for current month and year a go month
i could you please guide me builting report for current monthwise for current month and year a ago month
report parameter month_year='06-2010'
tables = sales and below are the table fields
customer_id
invoice_dt
invoice_am
thanks
nhmOkay, Still you did not mention how you will pass value in report while generating.
Anyway the query with UNION ALL will work. For Example.
I am assuming that the parameter for date/month you will pass in range like 01-JUN-2010 to 30-JUN-2010
SELECT customer_id, SUM(curr_value) curr_value, SUM(past_value) past_value
FROM
SELECT customer_id, NVL(SUM(invoice_amount),0) curr_value, 0 past_value
FROM sales
WHERE invoice_dt BETWEEN :P_FROM_DATE AND :P_TO_DATE -- here P_FROM_DATE and P_TO_DATE will be the date range for current year as i showed above.
AND -- Any Condition goes here...
GROUP BY customer_id
UNION ALL
SELECT customer_id, 0, NVL(SUM(invoice_amount),0)
FROM sales
WHERE invoice_dt BETWEEN ADD_MONTHS(:P_FROM_DATE,-12) AND ADD_MONTHS(:P_TO_DATE,-12) -- This add_months function for the previous year same month.
AND -- Any condition goes here...
GROUP BY customer_id
GROUP BY customer_idNow using the above query you can design the tabular report as you showed the format.
-Ammad
Edited by: Ammad Ahmed on Jul 3, 2010 7:55 PM
added GROUP BY -
Daily, Monthly, and Yearly Report
Hi I am new to the BAM. I have a BPM process. I want to generate the daily, monthly and yearly report for it. Please advise how can I achieve it. I have a one dimension variable on the process.
Thanks in advance!Hi,
Try this query to get default ware house and its quantity and modify above query.
SELECT T0.[ItemCode], T0.[WhsCode], T0.[OnHand] FROM OITW T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode WHERE T0.[WhsCode] = T1.[DfltWH] and T1.[ItemCode] = [%0]
Thanks & Regards,
Nagarajan -
Table for Material Quantity and Value for particular month and year
Hi All
My requirement is that for a particular month and year I want to know the stock quantity and stock value for a particular material for a given plant.From which SAP table can I get this data as I want to fetch data for my Y report?
Regards
Satish KumarHi,
You can use MB5B table as suggested earlier.also you can use:
MBEW-VMKUM --> stock for previous month period
MBEW-VJKUM --> stock for previous year period
PLease view these links which migh tbe helpful to you:
http://help.sap.com/saphelp_47x200/helpdata/en/39/55fee3bc6111d4b3960050dadf0791/content.htm
TableStock
Thanks
Nisha
Maybe you are looking for
-
How to load multiple HTML5 canvas on the same page (the proper method)
Hi, I've been struggling to load multiple canvas animations on the same page. At the beggining I thought that exporting the movies with different namespaces and reloading the libraries in a sequential flow might work, but it doesn't. It always loads
-
Export and Import using Named Pipes
Hai, I need an clarification in export, import and compress of dumps using named pipes.I am using Oracle 9i RAC 9.2.0.4 in AIX 5.3. Every month i have to move list of tables from one database to another database after taking export dumps. The list of
-
What affects the default character set environment of JVM?
For Example, String.getBytes(); since not specify the characterset, so will use the system default characterset. what is this system default characterset affected by? I have tried in Linux Platform, which is LANG environment variable. Is this right?
-
Operation style: "rpc" not supported - HELP
Hi all, i have written a web service with a method called createNews which has an int value in input and get a vector in output. when i invoke the methos call.invoke e i get the error : operation style: "rpc" not supported ! The code of the JSP file
-
Can I find a theme that uses a color I choose?
I can't figure out how I can find themes that use a color I have selected. I would like to browse available themes based on a starting color I choose, is this possible?