How to get 13th of a Month
Dear Members,
I have to display 13th of a month when month and year are given as input.
For example i have a variable v1 whose value is AUG-2009. I should write a sql in such a way that the output day should be 13th. for this example the output should be 08/13/2009. If its OCT-2009 then the output should be 10/13/2009 ETC.....
How can we achieve this?
Thanks
Sandeep
Hi try this
SQL> select to_char(to_date('&V','MON-YYYY')+12,'MM/DD/YYYY') from dual;
Enter value for v: AUG-2009
old 1: select to_char(to_date('&V','MON-YYYY')+12,'MM/DD/YYYY') from dual
new 1: select to_char(to_date('AUG-2009','MON-YYYY')+12,'MM/DD/YYYY') from dual
TO_CHAR(TO
08/13/2009
Similar Messages
-
How to get count for missing month
I created a view as follows:
CREATE OR REPLACE FORCE VIEW "Vinfection1" ("MONTH", "COUNT") AS
select "MONTH","COUNT" from (
select to_char(s.pdate,'Mon-yyyy') as month, count(*) as count
from surproc s, diagnosis_surproc d
where s.surprocid = d.surprocid and d.diagnosisid in ('506', '507', '508', '509', '510')
group by to_char(pdate,'Mon-yyyy'))
order by to_date(month,'Mon-yyyy')
Some months are missing in the view. I want to put that month and 0 in the view. How to do it?
Thanks,
JenniferHi, Jennifer,
You need to outer-join to some table or result set (such as all_months, below) that has one roe per month.
Here's one way:
CREATE OR REPLACE FORCE VIEW Vinfection1 (month, month_s, cnt) AS
WITH all_months AS
SELECT ADD_MONTHS (first_month, LEVEL - 1) AS month
FROM (
SELECT TRUNC (MIN (pdate), 'MONTH') AS first_month
, TRUNC (MAX (pdate), 'MONTH') AS last_month
FROM surproc
CONNECT BY LEVEL <= 1 + MONTHS_NETWEEN (last_month, first_month)
SELECT a.month
, TO_CHAR (a.month, 'Mon-yyyy') AS month_s
, COUNT (*) AS cnt
FROM all_months a
LEFT OUTER JOIN ( surproc s
JOIN diagnosis_surproc d ON s.surprocid = d.surprocid
AND d.diagnosisid IN ('506', '507', '508', '509', '510')
) ON a.month = TRUNC (s.pdate)
GROUP BY a.month
/Avoid table- and column names that are non-standatrd (such as names that need double-quotes), or are built-in function names (such as COUNT).
Don't use ORDER BY in a view. Almost anything you do with the view will cause the ordering to be lost anyway.
Even if you do have an ORDER BY clause in the view, you'll often want to ORDER BY month. Rather than call TO_DATE whenever you need to sort, I suggest having two month columns; month (whcih is a DATE) for sorting, filtering and joining, and month_s (whcih is a VARCHAR2) for displaying.
Use ANSI join syntax, especiallly for outer joins.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using.
Edited by: Frank Kulash on Mar 20, 2012 12:03 PM
Added outer join condition -
How to get name of the month from current date.
Hi,
How to get the name of the month from current date.
Thanks,
SenthilSethil,
Use your date(let us say Date1) instead of sy-datum.
CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
LANGUAGE = SY-LANGU
IMPORTING
RETURN_CODE =
TABLES
MONTH_NAMES = itab_month
EXCEPTIONS
MONTH_NAMES_NOT_FOUND = 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.
READ TABLE itab_month
WITH KEY MNR = date1+4(2).
itab_month-LTX will contain the value you are looking for
Good luck
Raghava -
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 sincerelyCan 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 -
How to get last date of month ?
Dear all
hi!!!
How can I get the last date of a particular month?
I mean if the month is Feb, last date of the month should be 28.
Is it required to write in loop or there is any method to get it.
Please write me urgently,
thanx,
SamirHello ,
You can get the last date of a particular month of a particular year like this :
int year= 2000;
int month=1; // February (month is zero based )
int date = 20;
java.util.GregorianCalendar gc = new java.util.GregorianCalendar(year,month,date);
int last_day = gc.getActualMaximum(Calendar.DAY_OF_MONTH));
Sandip -
SSRS how to get for number of months
Hi All;
below is my SSRS expression
=Cdate(Format(Cdate(Mid(Fields!createdon.Value,4,2) & "/" & Mid(Fields!createdon.Value,1,2) & "/" & Mid(Fields!createdon.Value,7,4)),"MMMM yyyy"))
which gives me the month in MMMM yyyy format in Jan 2014, Feb 2014, Mar 2014... so on
i need to remove a average of a month
i.e Months value/No of months
I do i get number of months dynamically in SSRS
Any help much appreciated
Thanks
Pradnya07Hi Pradnya07,
In your scenario, it seems that the createdon is a string data type field with this format: 15/09/2014.
If we want to get the number of the month in the createdon field, we can directly use the expression below:
=cint(Mid(Fields!createdon.Value,4,2))
If you also need to get the average data for a month like ‘Months value/No of months’, please refer to the following expression:
= Fields!Amount.Value /cint(Mid(Fields!createdon.Value,4,2))
If there are any misunderstanding, please elaborate the issue for further investigation.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
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).
-
How to get the free 6 months xsplit gamecaster
can anyone help me with that
Dear Pegasus and hch,
Thank you both for your replies, and attempt to help much appreciated.
First pegasus: i have tried the link and entering my serial into the event downloader, and it comes back with a barcode error.
When i get home i will go trough the dvd's one more time just to check if i missed something.
For pegasus and hch, i have tried the pre installed XSplit gamecaster (not with MSI logo btw) and upon creating a new account it directly says i needed to update xsplit version of gamecaster. now the first 3 times i didnt update becasue i allready found this thread before doing so. but finaly i decided to upgrade the version. this also does not give me the 6 month trial. just the free account.
Factory resetting the laptop as is now will require another day of setting my machine up just the way i like it and that is now not an option, im trying to get this solved without having to revert to a just reset the entire laptop solution.
actualy that link pegasus showed made me most hopefull.
Also logged this issue with MSI support about 3 weeks ago but havent received a reply whatsoever.
Ill keep on trying. ill let you guyz know if i find something in the booklet and dvd pouch.
p.s. i am from the netherlands, so if anyone else has some info if the included and marketed to be included XSplit Gamecaster is not included in dutch versions of this amazing laptop (for reasons that would defenatly elude me) -
How to get aggregation at Year-Month level??
Hi experts,
I've Date and Qty column in rpd. I've created the aggregated column in rpd with Sum aggregation (Sum Qty)
My report is coming in this format..
Date...........Sum(qty)
1/1/2009..........5
1/2/2009..........4
1/6/2009..........10
2/3/2009.........2
2/4/2009..........6
But I need the report like this....
Year-Mon.........Sum(qty)
2009-01-----------19
2009-02-----------8
Please helphi bob,
1) Create a logical column yyyy/mm format using date col
CAST ( EXTRACT( YEAR FROM "Sample".""."Samplesales"."Dim-Date"."Start Date") AS CHARACTER ( 4 )) || '/' || CASE WHEN EXTRACT( MONTH FROM "Sample".""."Samplesales"."Dim-Date"."Start Date") BETWEEN 10 AND 12 THEN CAST ( EXTRACT( MONTH FROM "Sample".""."Samplesales"."Dim-Date"."Start Date") AS CHARACTER ( 2 )) ELSE '0' || CAST ( EXTRACT( MONTH FROM "Sample".""."Samplesales"."Dim-Date"."Start Date") AS CHARACTER ( 1 )) END
2) Set the aggregate/content level to this column (yyyy/mm) format to the fact table
thanks,
saichand.v -
I want to select all dates that may occur in the month.
suppose if i enter jun-2008
then select will return dates from 1-jun-2008 to 30-jun-2008;
I thought this will be done via using all_objects trick,
Regards
Danish HayderIt needs a little change in this code -
satyaki>
satyaki>select to_date('01-'||upper('&dt'),'DD-MON-YYYY') -1 + rownum dates
2 from dual
3 connect by rownum <= (
4 last_day(to_date('01-'||upper('&dt1'),'DD-MON-YYYY')) -
5 to_date('01-'||upper('&dt'),'DD-MON-YYYY') +1
6 );
Enter value for dt: may-2008
old 1: select to_date('01-'||upper('&dt'),'DD-MON-YYYY') -1 + rownum dates
new 1: select to_date('01-'||upper('may-2008'),'DD-MON-YYYY') -1 + rownum dates
Enter value for dt1: jun-2008
old 4: last_day(to_date('01-'||upper('&dt1'),'DD-MON-YYYY')) -
new 4: last_day(to_date('01-'||upper('jun-2008'),'DD-MON-YYYY')) -
Enter value for dt: may-2008
old 5: to_date('01-'||upper('&dt'),'DD-MON-YYYY') +1
new 5: to_date('01-'||upper('may-2008'),'DD-MON-YYYY') +1
DATES
01-MAY-08
02-MAY-08
03-MAY-08
04-MAY-08
05-MAY-08
06-MAY-08
07-MAY-08
08-MAY-08
09-MAY-08
10-MAY-08
11-MAY-08
DATES
12-MAY-08
13-MAY-08
14-MAY-08
15-MAY-08
16-MAY-08
17-MAY-08
18-MAY-08
19-MAY-08
20-MAY-08
21-MAY-08
22-MAY-08
DATES
23-MAY-08
24-MAY-08
25-MAY-08
26-MAY-08
27-MAY-08
28-MAY-08
29-MAY-08
30-MAY-08
31-MAY-08
01-JUN-08
02-JUN-08
DATES
03-JUN-08
04-JUN-08
05-JUN-08
06-JUN-08
07-JUN-08
08-JUN-08
09-JUN-08
10-JUN-08
11-JUN-08
12-JUN-08
13-JUN-08
DATES
14-JUN-08
15-JUN-08
16-JUN-08
17-JUN-08
18-JUN-08
19-JUN-08
20-JUN-08
21-JUN-08
22-JUN-08
23-JUN-08
24-JUN-08
DATES
25-JUN-08
26-JUN-08
27-JUN-08
28-JUN-08
29-JUN-08
30-JUN-08
61 rows selected.
satyaki>Hope this will work.
Regards.
Satyaki De. -
please tell me how to get total days in month by calendar:
suppose i pass these parameters in calendar:=
Calendar c1=new GregorianCalendar(2005,1,6);
means it is feb 2005
now i want to find the No of days in current month:
it should give 28 .
please tell how to get.progarmatically i know.
i want APIHi,
I don't know if you got it working or not, but I was looking for the same thing and I found the following at this address
http://javaalmanac.com/egs/java.util/GetDaysInMonth.html
// Create a calendar object of the desired month
Calendar cal = new GregorianCalendar(1999, Calendar.FEBRUARY, 1);
// Get the number of days in that month
int days = cal.getActualMaximum(Calendar.DAY_OF_MONTH); // 28
// Try month in a leap year
cal = new GregorianCalendar(2000, Calendar.FEBRUARY, 1);
days = cal.getActualMaximum(Calendar.DAY_OF_MONTH); // 29 -
Hi all,
Can anyone suggest me a logic for the following requriment.
How to get 1st of every month with out using '-' operator?
Thanks in advance
Cheers
Nirmal...but don't forget to convert it back to a date, and to use 4 digit years:
SQL> SELECT TO_DATE('01-'||TO_CHAR(sysdate,'MON-YYYY'),'DD-MON-YYYY') FROM DUAL;
TO_DATE('
01-JUN-06
SQL> alter session set nls_date_format='dd/mm/yyyy';
Session altered.
SQL> SELECT TO_DATE('01-'||TO_CHAR(sysdate,'MON-YYYY'),'DD-MON-YYYY') FROM DUAL;
TO_DATE('0
01/06/2006Dates and strings are not equivalent and a date does not hold any display formatting information...it is only formatted when converted to a string either explicitly by using to_char, or implicitly using the nls settings
HTH
David -
I have a situation, where i need to write expression Period to date(PTD). i want to know how to get the period date. i want you to help in writing Period date or else is there any function to get period date for a given date(the date is given
from the parameter dynamically) in MDX for SSRS report
ramHi ram,
Per my understanding that you want to get the period date based on the month selected and the given date, right?
Could you please provide details information below to help us better understanding your requirements, thus we will be more effective to provide an solution:
What is the format of the period date you want to get, is this date in the DB and you want to filter it based on the month and the given Date?
Did the month and given date are two parameters in the report? if possible, could you please provide some sample data in the DB and also the snapshot of the report structure
I assume you want to get the period date(mm/dd/yyy) between the select month(e.g:Feb) and the given date (10/1/2014) and you should get the date between(02/01/2014-10/1/2014).
If so,and you also have two parameter "Month","EndDate"(EndDate is the given date), please reference to details information below:
You can create an new parameter "BeginDate" (Date/Time) which is the begin date of the period, you can use the expression to get the value based on the value of the month and the year value from the given date,finally hide this parameter:
Specify the available value:
Label:=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value)
Value:=CDate(=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value))
Specify the default Value:
Value:=CDate(=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value))
Add filter to the dataset as below:
Preview you will get all the date in the given Period:
If you still have any problem, please feel free to ask.
Regards
Vicky Liu -
How to get the last day of a month?
HI,
I want to know how to get the last day of a month.
In my JClient form, I tried to get it by using oracle.sql.Date method, that is:
lastday=oracle.sql.Date anydate.lastDayOfMonth();
But it does not work. The result is lastday=anydate.
Why?
StephenYou can use the Calender class...
Calendar c = Calendar.getInstance();
and then something like...
c.add(c.MONTH, 1);
int dayOfMonth = c.get(Calender.MONTH);
c.add(c.DAY_OF_MONTH, - (dayOfMonth-1) );
other usefull functions are:
System.out.println(" YEAR : " + c.get(Calendar.YEAR));
System.out.println(" MONTH : " + c.get(Calendar.MONTH));
System.out.println(" DAY_OF_MONTH : " + c.get(Calendar.DAY_OF_MONTH));
System.out.println(" DAY_OF_WEEK : " + c.get(Calendar.DAY_OF_WEEK));
System.out.println(" DAY_OF_YEAR : " + c.get(Calendar.DAY_OF_YEAR));
System.out.println(" WEEK_OF_YEAR : " + c.get(Calendar.WEEK_OF_YEAR));
System.out.println(" WEEK_OF_MONTH : " + c.get(Calendar.WEEK_OF_MONTH));
System.out.println(" DAY_OF_WEEK_IN_MONTH : " + c.get(Calendar.DAY_OF_WEEK_IN_MONTH));
System.out.println(" HOUR : " + c.get(Calendar.HOUR));
System.out.println(" AM_PM : " + c.get(Calendar.AM_PM));
System.out.println(" HOUR_OF_DAY (24-hour): " + c.get(Calendar.HOUR_OF_DAY));
System.out.println(" MINUTE : " + c.get(Calendar.MINUTE));
System.out.println(" SECOND : " + c.get(Calendar.SECOND));
System.out.println();*/ -
I purchased a monthly pack and havent been able to use it. I have been getting charged for 3 months now and I still get an error message saying "unable to load all your plans". How do I re-install or dowload and get my last 3 payments reimbursed?
Link for Download & Install & Setup & Activation problems may help
-Online Chat http://www.adobe.com/support/download-install/supportinfo/
or
Adobe contact information - http://helpx.adobe.com/contact.html
Maybe you are looking for
-
Formula is not working in report
Hi Friends, This is formula iam using in report.but in output iam getting only value 1. Iam not getting other values. I think my OR condition is not working. ( ( ( ( ( 'KF1' < 0.1000 ) * 1 OR ( ( 'KF1' >= 0.1000 ) AND ( 'KF1' < 0.1200 ) ) * 2 ) OR (
-
I'm trying to install tiger woods pga tour 2005. Its telling me to free up local disk space
-
Problems send photos by e-mailv
I find that when I send one or more photos from LR3 by e-mail, recipients are receiving all the photos on the main page of the e-mail. I need to send only the jpg file(s) so that the Editor and the Printer of a magazine can exchange views about them.
-
Hi. Could someone confirm if Mapping from EXP to PRE to COS is automatic in any router? in my case I am ussing an 7600 with SIP-400. In other case I am ussing the same 7600 with a WS card. I am worried about the mapping between PRE to COS. Tranks.
-
Interactive Adobe form for performance appraisal
Hi Experts, Is it possible to create Interactive Adobe Form for Performance appraisal? I understand that the appraisal template varies company to company.Does it affect the Form? Can we update the infotype 0025 ( Appraisals where appraisee /Appraisal