get the month and year of date type
Hi allI need to get the month and year of type date.
For example
select to_date('2011-01-17', 'yyyy-mm-dd') from dual;
Required result:01-2011
Any ideas?Thanks in advance,
Bahchevanov.
select to_char(to_date('2011-01-17', 'yyyy-mm-dd'),'mm-yyyy') from dual;
HTH
Tags: Database
Similar Questions
-
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>
-
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;
}
-
Hide the 0 before the month and year
I m using this query to generate the sequence
The result isSELECT TO_CHAR (SYSDATE, 'MM') || TO_CHAR (SEQ.NEXTVAL) || TO_CHAR (SYSDATE, 'YY') FROM DUAL;
06 is the month0612109
121 is the sequence
09 is the year
I want to hide 0 before the month and the year also.
Looks like this
* 61219 *.if here Month is 10 and year is 2010 then It will display 1021110
Try this
SQL> SELECT ltrim(TO_CHAR(to_date('12-10-2010','dd-mm-yyyy'), 'MM'),'0') 2 || TO_CHAR (SEQ.NEXTVAL) 3 || ltrim(TO_CHAR (to_date('12-10-2010','dd-mm-yyyy'), 'YY'),'0') format_date 4 FROM DUAL; FORMAT_DATE -------------------------------------------- 1026010
-
Today's date in the month and year
Dear experts,
I have a year and the number of the day, I wanted to identify the date
ex: number of days = 203 year = 2009
Date: 22/07/2009
Please advice the best way possible to achieve.
Thank youDear user!
Please try this code.
SELECT TO_DATE(2032009, 'DDDYYYY') as dateval FROM dual; DATEVAL ------------------- 22.07.2009 00:00:00
This figure first three are the day number and the last four digits are the year. The DDD format will give you the day and the month as JJ.MM. YYYY format join the year your date. To do this, try:
SELECT TO_DATE(2032008, 'DDDYYYY') as dateval FROM dual; DATEVAL ------------------- 21.07.2008 00:00:00
Yours sincerely
Florian W.
Published by: Florian W. the 22.07.2009 08:40
-
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;
-
Aggregation of week, month, and year to date
Nice day
I have a requirement which led to thinking me where I summarize the value of sales at three levels - year_to_date, month_to_date and week_to_date. It's easy for me to represent the annual and monthly version, I need to do a bit of logic to get the weekly Variant.
The function definitions are
year_to_date: sum up the record sales since January 1 to sysdate
month_to_date: summarize all record sales of the 1st of the current month to sysdate
week_to_date: summarize all record sales of 12: 00 a.m. Monday in the current week to sysdate
Is that they are all these functions sql oracle to achieve? I googled and also search for the oracle 10g R2 sql reference and did not find what I was looking for? Does anyone know a web reference where I could find a solution.
table definition
=============
ID number (6)
date of trans_date
number of sales_value (15: 4)
receipt_no varchar2 (20)
Thank youSQL> create table mytable (id,trans_date,sales_value,receipt_no) 2 as 3 select 1, date '2009-07-01', 10, 'A' from dual union all 4 select 2, date '2010-01-01', 20, 'B' from dual union all 5 select 3, date '2010-04-01', 30, 'C' from dual union all 6 select 4, date '2010-09-02', 40, 'D' from dual union all 7 select 5, date '2010-09-11', 50, 'E' from dual union all 8 select 6, date '2010-09-13', 60, 'F' from dual union all 9 select 7, date '2010-09-13', 70, 'G' from dual 10 / Table created. SQL> select sum(sales_value) ytd 2 , sum(case trunc(trans_date,'mm') when trunc(sysdate,'mm') then sales_value end) mtd 3 , sum(case trunc(trans_date,'iw') when trunc(sysdate,'iw') then sales_value end) wtd 4 from mytable 5 where trans_date >= trunc(sysdate,'y') 6 / YTD MTD WTD ---------- ---------- ---------- 270 220 130 1 row selected.
Kind regards
Rob. -
Error definition day LOV based on the month and year
Select ' 1 ', ' 01' day_aff union double val
...
Select '29', ' 29 "double where '29' < = to_char (last_day (to_date ('01.' |)))" '02'. '.' || (((', 'dd.mm.yyyy')), 'jj') union
Select '30', ' 30 "double where '30' < = to_char (last_day (to_date ('01.' |)))" '02'. '.' || (((', 'dd.mm.yyyy')), 'jj') union
Select '31', '31' from dual where '31' < = to_char (last_day (to_date ('01.' |))) '02'. '.' || (((', 'dd.mm.yyyy')), 'jj')
order by 2
That works well.
If I replace '02' by: P10_MONTH & P10_MONTH. or v ('P10_MONTH') and 2008 by: P10_YEAR & P10_YEAR. or v ('P10_YEAR'), I get the following error on the creation of LOV (in shared components or LOV section of the element):
LOV query is not valid, a display and a return value is needed, the column names must be different. If your query contains a query online, the first CLAUSE in the SQL statement must not belong to the query online.
No work around?
IgorHi Igor,.
I think it's the | in the SQL that is causing the problem. You can get around this by the presence of a hidden page element which is calculated at the point of process before header which calculates the first day of the selected month.
I did it on this page: [http://apex.oracle.com/pls/otn/f?p=35917:16]
In addition, you can simplify your SQL statement to something like:
SELECT LEVEL d, LEVEL r FROM DUAL CONNECT BY LEVEL <= TO_NUMBER(TO_CHAR(LAST_DAY(TO_DATE(v('P16_FIRSTDATE'),'DD/MM/YYYY')),'DD'))
(P16_FIRSTDATE is the element that contains the calculated date)
Andy
-
Query to get the numbers and percent by date range
11g version.
Hello
I have the following data in the format
I want to get all the charges and % of all users who have accepted_flag the value n. basically, users who have not yet accepted in the format of Opty_id.Opty_Id creation_date user accepted_flag 1 01-mar-2013 ryan N 2 02-mar-2013 sam Y 3 02-mar-2013 ryan Y . . .
The column of aging is creation_date, basically, how much body id, were created between now and 20 days, 21-40 and 41-60 days and have not yet accepted (accept the flag = N)ageing count Percentage 0-20 days 1 10%(this will offcourse depend on the total number of opty id and then out of that how many did not accept within the given period. 21-40 days 0 0% 41-60 days 0 0%
Any help please.
Thank you
RyanI get other results
with t as (select 1 as opty_id, to_date('01/03/2013','DD/MM/YYYY') as date_created, 'ryan' as auser, 'N' as accepted_flag from dual union all select 2, to_date('02/03/2013','DD/MM/YYYY'), 'sun', 'Y' from dual union all select 3, to_date('03/02/2013','DD/MM/YYYY'), 'sun', 'Y' from dual union all select 4, to_date('02/01/2013','DD/MM/YYYY'), 'ryan', 'N' from dual union all select 5, to_date('03/01/2013','DD/MM/YYYY'), 'tom', 'Y' from dual) select decode(grp,1,0,grp*20-19) ||'-'|| grp*20 ageing ,sum(case accepted_flag when 'N' then 1 else 0 end) count ,sum(case accepted_flag when 'N' then 1 else 0 end) /sum(sum(case accepted_flag when 'N' then 1 else 0 end)) over () Percentage from (select ceil(decode((trunc(sysdate) - date_created),0,1,trunc(sysdate) - date_created)/20) grp ,date_created ,accepted_flag from t ) group by grp AGEING COUNT PERCENTAGE "0-20" "1" "0,5" "21-40" "0" "0" "41-60" "0" "0" "61-80" "1" "0,5"
Published by: chris227 on 04.03.2013 03:41
Modified according to response below -
How to find the sum of the month and year of a date
Hi all
I want to find the sum of the date
for example, 10 November 2010 I need to find (11-2010).
Please help meYou can use the extract function...
SQL> select extract(month from systimestamp)+extract(year from systimestamp) from dual; EXTRACT(MONTHFROMSYSTIMESTAMP)+EXTRACT(YEARFROMSYSTIMESTAMP) ------------------------------------------------------------ 2021
Concerning
Renjith Malet -
problem to insert only month and year instead of the full date
Hi, can someone help me how I can register only the month and year of the value which have full day in the database?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_daftar
for example, the date is 18/09/2012, but I want to just insert 09/2012 as a parameter. If I want to insert only one setting, I can do... But I have problem when I want to insert two parameters...Lina saleh wrote:
I already try before that and he invites me error like this...
"name of the invalid host/identification variable.Change the name of the connection variable to: from_date and: to_date
Is a reserved keyword.
-
How to set the filter criteria for the month and the year to aid in the timestamp input field?
Hello
I use jdev 11.1.2.3.
I have a problem with the generation of reports, I have a report table that is in the form of VO (query based) and I want to search this table in the month and year of the basic
but in this table (query) This timestamp field of having value based on... How to do a search with the name of the month and year only... Here I totally use vo base query to generate a
reports... Anyone can guide me.
Thank you.
I want to create a drop-down list for month + year as an executable parameters with bind variable no matter what idea this subject, my attribute here is TimestampFormat.
Then add to your sql query something like:
WHERE extract (your_timestamp_column MONTHS) =: monthBindVar
OR an extract (YEAR your_timestamp_column) =: yearBindVar
and add monthBindVar and yearBindVar as a bind variable to your view object.
Then you can use it as a ExecuteWithParams operation (or manually set these bind variables and execute the query)
Dario
-
Get the number of days, months and year
Hi all
I'm using OBIEE 11 g. I have a line of dash for year (2010, 2011, etc.) and months (Jan, Feb,..., Dec). How can I get the number of days in a given month and year in my report?
For example, if I choose to Jan & 2011, I'd get 31 and 356. And if I choose Feb & 2011, I would get 28 and 356.
Thank you!I have something more good option here... Try to use this
DAYOFMONTH (TIMESTAMPADD (SQL_TSI_DAY, DAYOFMONTH (CURRENT_DATE) *-1, TIMESTAMPADD (SQL_TSI_MONTH, 1, CURRENT_DATE)))
This will give you the days for the month in progress (Oct 2011) after calculating the last day of each month... Similary dynamically pass the value Date or month... You will need to modify this function but shud be simple. Hope this helps :)
-
Get the name and the data type into an object?
Hello
I would like to know if there is a way to get the names and the types of data encapsulated in an object of labview?
For example, let's say I make a simple object, called myObject to be commonplace, with private data: myObjectName (string), myObjectValue (int 32) (etc.)
So, how to build a method to return the type of the data of myObjectValue, or infact back the names and types of all data in the object field, which could be a lot?
Thank you
Paul.
-
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')
Maybe you are looking for
-
Application of office messages frequently fails to deliver messages to Android phones
When you send an SMS messages to an Android user via the 'Messages' application on the desktop, I often get an error "not delivered". Sometimes, if I connect to my Apple account in the section 'Preferences' from the Messages app and then reconnect it
-
Hello Has anyone encountered this problem? My account is temporarily suspended: I'm asking a verification code to my phone by text service. but after entering my phone number, I get the message: Service not available. Please try again later. All flow
-
When searching for files/folders, cannot find the files that need to be there
Search all files/folders c & d, where I can look? These would be fragments of deleted files? * original title - search/run can not find the files I know are there. I see their names flashing by when I'm doing a full scan, so they must exist - anoth
-
How can I attach and send photos in Hotmail?
known using hotmail How to attach photo and and send it by email
-
Question about docking station is impermeable to water
There is an important question: If during the Xperia Z2 charge in the docking station (with closed cards) I accidentally pour water on it, what consequences will have?