How to get the month previous year?
Hello
I have to get the previous year three-months of the effective date, but I have a problem since the beginning of the year and it's because I set the incorrect query.
I mean:
I wrote this query
SELECT TO_CHAR(SYSDATE,'YYYYMM')-1, 2-TO_CHAR(SYSDATE,'YYYYMM'), TO_CHAR(SYSDATE,'YYYYMM')-3
FROM DUAL;
in order to get (on mars):
201502, 201501, 201412
but unfortunately, I get:
201502, 201501, 201500
Can you help me?
Thanks in advance!
Hello
Here's one way:
SELECT TO_CHAR (ADD_MONTHS (SYSDATE-1), "YYYYMM") AS the m1
, TO_CHAR (ADD_MONTHS (SYSDATE-2), "YYYYMM") AS m2
, TO_CHAR (ADD_MONTHS (SYSDATE,-3), "YYYYMM") M3
DOUBLE;
Tags: Database
Similar Questions
-
get the month and year of date type
Hi all
I need to get the month and year of type date.
For example
Required result:select to_date('2011-01-17', 'yyyy-mm-dd') from dual;
Any ideas?01-2011
Thanks in advance,
Bahchevanov.select to_char(to_date('2011-01-17', 'yyyy-mm-dd'),'mm-yyyy') from dual;
HTH
-
How to get the Nth largest year in the query
Hi friends,
This is the query that I have and I want the Nth largest years wages in this table
If this table is retruning year like 2010,2009,2008,2007 etc.
SELECT *.
FROM (SELECT the YEAR, MONTH, employee_number, POSITION, payroll_name, dept, status, termination_date, full_name,)
ROW_NUMBER () OVER (PARTITION BY employee_number, basic_salary ORDER BY YEAR, MONTH) top3,
DECODE (basic_salary,
100000, 4500,
24000, 1921
basic_salary
) basic_salary
OF kdd_pay_hr_sal_vw
WHERE employee_number =: p_emp_num
order by year desc)
WHERE top3 < = 1
--------------------------------------------------------
MONTH YEAR EMPLOYEE_NUMBER POSITION STATUS FULL_NAME TOP3 BASIC_SALARY TERMINATION_DATE DEPT
04 2010 4741 senior oracle Engineer 690-computer used JIHAD ABBAS HARB 1.00 1,600.00
How to do it pls helpHello
You must remove partition by clause basic_salary. And you must order by year and month of the desc.
Try this,
SELECT * FROM ( SELECT MONTH ,YEAR ,employee_number ,POSITION ,payroll_name ,dept ,status ,termination_date ,full_name ,ROW_NUMBER () OVER (PARTITION BY employee_number ORDER BY YEAR DESC, MONTH DESC) top3 ,DECODE (basic_salary, 100000, 4500, 24000, 1921, basic_salary) basic_salary FROM kdd_pay_hr_sal_vw WHERE employee_number = :p_emp_num ORDER BY YEAR DESC) WHERE top3 = 1
G.
-
to get the month and year separated
Hello
I have the entry_date_fin of column (type of data-varchar2 (8))
with values like Apr.-2008
Feb-2009 etc.
can I get the distinct month and year separated
kindly guide mei tried select to_date(entry_date_fin,'MM') FROM xyz doesnt wrk
Although you are (wrongly, IMO) storage of dates as strings, just use string manipulation...
SQL> with t as (select 'FEB-2008' as txt from dual) 2 -- 3 select substr(txt,1,3) as mnth 4 ,substr(txt,5) as yr 5 from t 6 / MNT YR --- ---- FEB 2008 SQL>
-
How to get the Date, month, year of the DateTimePicker
Hi, I am using the DateTimePicker.
There are several question about this command:
1. how to get the Date, month and year?
-With the help of myDateTime.value, I get this string ' Wed May 08 14:45 ICT 2013 '-> I have to manually analyze this? Because I need in format yyyy/mm/dd. Or can set the format of dateTimePicker.value?
2 format on dateTimePicker self (on the user interface) is d/m/YY, I can't change to another format?
Thank you
dateTimePicker.value return a QDateTime not a string.
https://developer.BlackBerry.com/Cascades/reference/bb__cascades__datetimepicker.html#property-value
See more:
https://developer.BlackBerry.com/Cascades/reference/QDateTime.html#date
https://developer.BlackBerry.com/Cascades/reference/QDate.html
You can get
day = dateTimePicker.value.date().day() month = dateTimePicker.value.date().month() year= dateTimePicker.value.date().year() dateYYYYMMDD = dateTimePicker.value.date().toString(Qt::ISODate) dateYYYYMMDD2 = dateTimePicker.value.date().toString("YYYY/MM/DD") dateYYYYMMDD3 = dateTimePicker.value.toString("YYYY/MM/DD")
-
How to get the maximum number of days in a month?
How to get the maximum number of days in a month?
I use a dateField. where I can get the month. Now, I want to get the maximum number of days in a month.
How can I get it?
Please help me. and thanks in advance... []
NET. RIM. Device.API.util
Class DateTimeUtilitiesgetNumberOfDaysInMonth (int month, int year)
Returns the number of days in the specified monthIt took me like 10 seconds to find it in the API, I guess you spent more time writing the post...
-
Get the number of days in a month based on the month and year of fields
I have a column in my form which lists the days in a month. I want to configure a hidden field that calculates the total number of days in a month, based on the month and year of the field inputs. The number of days will determine what appears on the column. For example, if I put 4 months, and 2016 in the field of the year, I get 30 in the hidden field. Thus, on the column 'Day', I'll have numbers 1-30. Or if I put 2 months and 2016 in the field of the year, I get the 29 in the hidden field. If the numbers 1-29 appears in the column 'day '.
Found this on some forum javascript code:
//Month is 1 based
function daysInMonth(month,year) {
return new Date(year, month, 0).getDate();
}
//July
daysInMonth(7,2009); //31
//February
daysInMonth(2,2009); //28
daysInMonth(2,2008); //29I do not know how to convert this code in JavaScript to adobe and don't really know how to use it. All I know how to do is to configure the field values for the field month and year as variables. I am a novice programmer and would appreciate it really all the help I can get. Thank you in advance!
The code seems to be JavaScript and runs as needed by using the JavaScript console.
I would like to consider making more general code, so if you have a date string that includes at least the month and year we could just call the function and get the number of days for that month.
The following script will calculate the number of days in a month, by using at least the month and year values can display the result on the JavaScript console and all of the value field for the field that has this code as the custom calculation Script.
function daysInMonth (oDate) {}
return new Date (oDate.getFullYear (), oDate.getMonth () + 1, 0) .getDate ();
}nMonth var = this.getField("Month").valueAsString; get the value of month;
nYear var = this.getField("Year").valueAsString; get the value of the year;Event.Value = "";
If (nMonth! = "" & nYear!) = "") {}
var MyDate = util.scand ("' / mm/yyyy ', nMonth +" / "+ nYear); convert to date object;
var nDaysInMonth = daysInMonth (MyDate); get the number of days;Console.Open (); Open the JavaScript console;
Console.clear(); clear the console;
Console.println ("Days in" + nMonth + ":" + nDaysInMonth); show days in month;
Event.Value = nDaysInMonth; Set the value of the field;
}
-
How to get the date for the first Monday of each month
Dear members,
How to get the date for the first Monday of each month.
I wrote the following code
SELECT decode (to_char (trunc (sysdate + 30, 'MM'), 'DAY'), 'MONDAY', trunc (sysdate + 30, 'MM'), NEXT_DAY (trunc (sysdate + 30, 'MM'), "LUN")) FROM DUAL
But he looks at complex bith.
Abhishek
Published by: 9999999 on 8 March 2013 04:30Use the IW format - it will make independent NLS solution. And all you need is truncated 7th day of each month using IW:
select sysdate current_date, trunc(trunc(sysdate,'mm') + 6,'iw') first_monday_the_month from dual / CURRENT_D FIRST_MON --------- --------- 08-MAR-13 04-MAR-13 SQL>
Here is the list of the first Monday of the month of this year:
with t as( select add_months(date '2013-1-1',level-1) dt from dual connect by level <= 12 ) select dt first_of_the_month, trunc(dt + 6,'iw') first_monday_the_month from t / FIRST_OF_ FIRST_MON --------- --------- 01-JAN-13 07-JAN-13 01-FEB-13 04-FEB-13 01-MAR-13 04-MAR-13 01-APR-13 01-APR-13 01-MAY-13 06-MAY-13 01-JUN-13 03-JUN-13 01-JUL-13 01-JUL-13 01-AUG-13 05-AUG-13 01-SEP-13 02-SEP-13 01-OCT-13 07-OCT-13 01-NOV-13 04-NOV-13 FIRST_OF_ FIRST_MON --------- --------- 01-DEC-13 02-DEC-13 12 rows selected. SQL>
SY.
-
How to get the product key I purchased previously?
How to get the product key I purchased previously?
Depends entirely on how you bought it in the 1st place.
A boxed product should have the key on the DVD case, which is the only trace.
An update Anytime, you should have the key in an e-mail message from Microsoft. If you log in the website to store, you should be able to find the email conversation.
If another provider such as a key, then you will need to go back to them.
If your Windows starts now while you can use a keyfinder utility to read the registry key.
-
How to get the last date of 3 days for the current month?
Hello. Guy
How to get the last date of 3 days for the current month?
MY OUTPUT WOULD LOOK LIKE THIS
JANUARY 29, 2016
JANUARY 30, 2016
JANUARY 31, 2016
GUYS HELP ME / / /...
SQL > select last_day (sysdate) - level + 1 double connect by level<= 3="" order="" by="">=>
LAST_DAY)
---------
29 JANUARY 16
30 JANUARY 16
31 JANUARY 16
-
How to get the second and third weekend of every month over a period of time?
Hello
No idea how to get the second and third weekend of every month on a given period without use of CLAUSE?
Thanks in advance.
Try it below,
SELECT CASE WHEN TO_CHAR (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'DY') = 'SAT '.
THEN ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)) + 1
WHERE TO_CHAR (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'DY') = 'Sun '.
THEN ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)) + 6
Of OTHER NEXT_DAY (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), "SAT") + 1
END as second_weekendday,
BOX WHEN TO_CHAR (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'DY') = 'SAT '.
THEN ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)) + 7
WHERE TO_CHAR (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'DY') = 'Sun '.
THEN ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)) + 7
Of OTHER NEXT_DAY (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), "SAT") + 7
END AS third_weekendday
FROM (SELECT SYSDATE startdate,
SYSDATE + 300 enddate
THE DOUBLE)
CONNECT BY LEVEL<=>=>
-
How to get the last day of a month for every 2 months for a given period?
Hello
Can is it some please let me know how to get the last day, last day of the week, the weekend last day, last Monday, one month for every 2 months for a given period?
Thanks in advance.
Try the below
SELECT LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))) lastday.
BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'SAT '.
SO LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))-1
WHERE TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'Sun '.
THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))-2
Of OTHER LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))
END as lastweekday,
BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') IN ('Sam', 'SUN')
THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))
Of OTHER LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))
-(TO_NUMBER (TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))),' from)) - 1).
END as lastweekendday,
BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'MY
THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))
Of OTHER NEXT_DAY (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), "LUN")-7
END AS lastmonday
FROM (SELECT SYSDATE startdate,
SYSDATE + 300 enddate
THE DOUBLE)
CONNECT BY LEVEL<=>=>
-
How to get the second Monday of each month in a given date range?
In Oracle forms, how to get the second Monday of each month in a given date range?
I tried below using the query WITH the Clause, but it seems that WITH Clause does not work in Oracle forms. So is there another way to do this in Oracle forms?
WITH month_range AS
(
SELECT TO_DATE ('Dec 2013', 'Mon YYYY') AS first_month
, TO_DATE ('Mar 2014', 'Mon YYYY') AS last_month
OF the double
)
SELECT NEXT_DAY (6 + ADD_MONTHS (first_month
, LEVEL - 1
)
, 'MONDAY '.
) AS second_monday
OF month_range
CONNECTION OF LEVEL < = 1 + MONTHS_BETWEEN (last_month, first_month)
;
Thanks in advance.
Good fishing, when the first day of the month is Thursday... So I changed the query accordingly... Try the below
SELECT CASE WHEN TO_CHAR (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'DY') = 'game '.
THEN NEXT_DAY (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'THU')
Of OTHER NEXT_DAY (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'Game') + 7
END AS second_day
FROM (SELECT SYSDATE startdate,
SYSDATE + 300 enddate
THE DOUBLE)
CONNECT BY LEVEL<=>=>
-
How can I order a list first for the year and sort the months each year?
Hello
I created a report that lists a number of items grouped by month, although elements it since 2012 so together and you spend your order is strange because the groups to report on 2 months.
example:
2013 - 01-50
01/2012 - 56
02/2013 - 45
02/2012 - 54
.
.
.
How do I ordernar first a year and and sort the months each year?
Sort by DATE... not VARCHAR2
It is a thing of database, not an APEX.
In your select statement to the report, the column for DATE information must be one data type DATE or another...
MK
PS - TRUNC (a_date_column, 'MONTH')
-
Select SQL - last day of the month, a year from now
Hello
How do we get the last day of the month, a year from now.
For example-sysdate-12/2/2009
Result - 31/12/2009
Thank youHello
SELECT LAST_DAY ( ADD_MONTHS ( SYSDATE , 12 ) ) FROM dual;
Remember, all DATEs, including the results of this query, include the hours minutes and seconds.
The hours, the minutes and the seconds returned by the above expression are the same as SYSDATE: If you run it at 15:43:30 today, it returns 15:43:30 on December 31, 2010. This can be important if you want to use an expression like this as the cut-off point in a WHERE clause.
Maybe you are looking for
-
Hard drive erase: leaving of Instructions for survivors
What could be the easiest instructions possible to leave my wife super-non-technical on how to erase the hard drive of my iMac? Medical diagnostics convince me I want to be better prepared that I was so far for all requirements.
-
Replacement of battery for Satellite L10-114
Hello I'm looking for a replacement battery for my Satellite L10, bought in September ' 05. Not the battery. is PA3420U-1BRS, 14, 4V Li-ion 4300mAh and I can't find an exact replacement on this site under the Accessories heading. This battery has bee
-
Received email Advisor deletion of user id
I just received an email last night at 11:10, indicating the following: ID has been locked By the end of 2015, we decide to delete all old accounts, as many users, open an account and do not use for a long time...Your ID has been selected for the del
-
Can I put an external resolution 1440 x 900 on Tecra A3X
Hello can I put a 19 Dell 1908WFP Ultra strong (1440 x 900) on a Tecra A3x position monitor interface?It's a wide screen, and must be run on the resolution of 1440 x 900. I have to make a presentation in England and cannot test it because the monitor
-
Does sony vaio support pro digital pen?
Do digital pen from sony vaio 13 pro support? If so it is compatible with any type of digital pen?