get the first week of the month
HelloHow to get the first week of the month of request
I tried this, but not gwtting
SELECT THE DOUBLE TO_CHAR('09/30/2007','W')
Thank you
Published by: 896398 on January 18, 2012 03:17
SQL> select to_char(to_date('07-12-2008', 'DD-MM-YYYY'), 'W') from dual;
T
-
1
SQL> select to_char(to_date('14-12-2008', 'DD-MM-YYYY'), 'W') from dual;
T
-
2
SQL> select to_char(to_date('23-12-2008', 'DD-MM-YYYY'), 'W') from dual;
T
-
4
HTH
Kind regards
NORTH CAROLINA
Tags: Database
Similar Questions
-
Is there one way other than to_char to get the month of the date field
Is there one way other than to_char to get the month of the date field
Hello
raj4tech wrote:
Is there one way other than to_char to get the month of the date field
EXTRACT is one:
SELECT INTERESTED (SYSDATE MONTHS) AS curr_month
DOUBLE;
-
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 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;
-
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>
-
Hello
I need to generate months between two bays. Last span should be up to sysmonth. I appreciate your time.
With the help of 10g or 11g
Required resultEFFECTIVE_MONTH DIST_ID SHOP_ID SHOP_NAME 01/01/2008 P00112 PFR00809 TOKEN GLASSES 06/01/2009 P00112 PFR00536 MAVALI GLASSES
EFFECTIVE_MONTH DIST_ID SHOP_ID SHOP_NAME SHOP_MONTH 1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Jan-2008 1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Feb-2008 1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Mar-2008 1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Apr-2008 1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-May-2008 1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Jun-2008 1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Jul-2008 1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Aug-2008 1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Sep-2008 1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Oct-2008 1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Nov-2008 1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Dec-2008 1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Jan-2009 1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Feb-2009 1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Mar-2009 1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Apr-2009 1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-May-2009 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Jun-2009 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Jul-2009 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Aug-2009 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Sep-2009 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Oct-2009 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Nov-2009 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Dec-2009 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Jan-2010 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Feb-2010 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Mar-2010 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Apr-2010 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-May-2010 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Jun-2010 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Jul-2010 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Aug-2010 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Sep-2010 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Oct-2010 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Nov-2010 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Dec-2010 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Jan-2011 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Feb-2011 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Mar-2011 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Apr-2011 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-May-2011 1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Jun-2011
Hello
Here's one way:
WITH got_month_cnt AS ( SELECT effective_month , dist_id , shop_id , shop_name , MONTHS_BETWEEN ( LEAD ( effective_month , 1 , ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH') , 1 ) ) OVER ( PARTITION BY dist_id ORDER BY effective_month ) , effective_month ) AS month_cnt FROM table_x ) SELECT c.effective_month , c.dist_id, c.shop_id, c.shop_name , ADD_MONTHS ( c.effective_month , m.column_value - 1 ) AS shop_month FROM got_month_cnt c CROSS JOIN TABLE ( CAST ( MULTISET ( SELECT LEVEL FROM dual CONNECT BY LEVEL <= c.month_cnt ) AS sys.odcinumberlist ) ) m ;
I'm just guessing at what role (if any) dist_id, shop_id and shop_name play in this issue.
I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using.Published by: Frank Kulash, June 8, 2011 17:38
-
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...
-
getting the value of the month
How to get the month value, my intention is that I have to get the month, julian months using it gives values from 1 to 12, but my intention is I want January as a text when 1 is filled and so on. Could you suggest on this.
Thank you
OlivierDominique, try this in the default value field: ToChar (Today (), "MMMM")
You can replace the today() with the field variable or the variable you need.
Good luck
Thom -
How could I get the second Friday of the month, given the month and year. In particular, want to know the second Friday of February and September for the whole year as next year or three years ago.
Hello
Assuming your NLS_DATE_LANGUAGE is in English:
NEXT_DAY ( TO_DATE (s, 'Mon YYYY') + 6 , 'FRI' ) AS second_friday
where s is a string like "Sep 2011".
To_date without a day of the month returns the 1st of the month.
Add 6 and you get at the end of the first week of this month.
NEXT_DAY reutns overnight with the abbreviation data (or name) after (not on) the 1st argument. -
Retrieve the month following the date
Hi people,
How can I get the part of months to a date.
Say, like, I want to get the month part (April = 4) 01/04/2009.
Thanks in advance!Hello
You can get all parts of a DATE using TO_CHAR.
For example, on April 1, 2009SELECT TO_CHAR (SYSDATE, 'Month') FROM dual;
product of the results of this
April
(if you use English) and
SELECT TO_CHAR (SYSDATE, 'MM') FROM dual;
produces this output (VARCHAR2)
04
-
Hello people:
I have currently a query that picks up all the weeks between a date range where my week starts on Thursday and ends on Wednesday. The following query works fine except that I need the week of beginning and end, from beginning and end Dates of months and the beginning and the Dates of end of the values of the settings, I'm passing. In this case, I chose January 1, 2013 to 31 December 2013.
Any help or pointers would be great!
Thank you!
Problem: I am picking up days of December 2012 as the first week began on December 27, 2012. In addition, in December, I'm pretty much lost last week as well (26 December - 31 December).
The request in hand:
SELECT first_thursday + (7 * (LEVEL - 1)) AS week_start_date, first_thursday + (7 * LEVEL) - 1 AS week_end_date FROM ( SELECT TRUNC(p_from_date + 4, 'IW') - 4 AS first_thursday, -- Week should start the pre ceeding THURSDAY based on the Start Date TRUNC( p_to_date + 4, 'IW') - 5 AS last_wednesday FROM ( SELECT to_date('01-JAN-2013') AS p_from_date, NVL(to_date('31-DEC-2013'), SYSDATE) AS p_to_date FROM dual ) parms ) end_points CONNECT BY LEVEL <= ( last_wednesday + 1 - first_thursday)/7;
Currently, this is the result I get (I'm only including the months of January and December here).
Week_Start_Date Week_End_Date 27-DEC-12 02-JAN-13 03-JAN-13 09-JAN-13 10-JAN-13 16-JAN-13 17-JAN-13 23-JAN-13 24-JAN-13 30-JAN-13 31-JAN-13 06-FEB-13
December:
28-NOV-13 04-DEC-13 05-DEC-13 11-DEC-13 12-DEC-13 18-DEC-13 19-DEC-13 25-DEC-13
What I would really like is based on start and end Dates, as well as the first and the last day of the month is similarly try nicely. I have provided and then gently break at the end of the month:
January:
01-JAN-13 02-JAN-13 03-JAN-13 09-JAN-13 10-JAN-13 16-JAN-13 17-JAN-13 23-JAN-13 24-JAN-13 30-JAN-13 31-JAN-13 31-JAN-13
February:
01-FEB-13 06-FEB-13 07-FEB-13 13-FEB-13 14-FEB-13 20-FEB-13 21-FEB-13 27-FEB-13 28-FEB-13 28-FEB-13
November:
31-OCT-13 06-NOV-13 07-NOV-13 13-NOV-13 14-NOV-13 20-NOV-13 21-NOV-13 27-NOV-13 28-NOV-13 04-DEC-13
December:
01-DEC-13 04-DEC-13 05-DEC-13 11-DEC-13 12-DEC-13 18-DEC-13 19-DEC-13 25-DEC-13 26-DEC-13 31-DEC-13
Hello
Roxyrollers wrote:
Hello people:
I have currently a query that picks up all the weeks between a date range where my week starts on Thursday and ends on Wednesday. The following query works fine except that I need the week of beginning and end, from beginning and end Dates of months and the beginning and the Dates of end of the values of the settings, I'm passing. In this case, I chose January 1, 2013 to 31 December 2013.
Any help or pointers would be great!
Thank you!
Problem: I am picking up days of December 2012 as the first week began on December 27, 2012. In addition, in December, I'm pretty much lost last week as well (26 December - 31 December).
The request in hand:
- First_thursday SELECT + (7 * (LEVEL - 1)) AS week_start_date,
- first_thursday + (7 * LEVEL)-1 AS week_end_date
- Of
- (
- SELECT TRUNC (p_from_date + 4, 'IW') - 4 AS first_thursday,-week should start to perform the pre-mounted THURSDAY based on the Start Date
- TRUNC (p_to_date + 4, 'IW') - 5 AS last_wednesday
- Of
- (
- SELECT to_date('01-JAN-2013') AS p_from_date,
- NVL (to_date('31-Dec-2013'), SYSDATE) AS p_to_date
- OF the double
- ) parms
- ) end_points
- CONNECT BY LEVEL<= (="" last_wednesday="" +="" 1="" -="">=>
Currently, this is the result I get (I'm only including the months of January and December here).
- Week_Start_Date Week_End_Date
- DECEMBER 27, 12 2 JANUARY 13
- JANUARY 3, 13 JANUARY 9, 13
- 10 JANUARY 13 JANUARY 16, 13
- 17 JANUARY 13 23 JANUARY 13
- 24 JANUARY 13 30 JANUARY 13
- 31 JANUARY 13 FEBRUARY 6, 13
December:
- NOVEMBER 28, 13 4 DECEMBER 13
- 5 DECEMBER 13 DECEMBER 11, 13
- 12 DECEMBER 13 18 DECEMBER 13
- 19 DECEMBER 13 DECEMBER 25, 13
What I would really like is based on start and end Dates, as well as the first and the last day of the month is similarly try nicely. I have provided and then gently break at the end of the month:
January:
- JANUARY 1, 13 2 JANUARY 13
- JANUARY 3, 13 JANUARY 9, 13
- 10 JANUARY 13 JANUARY 16, 13
- 17 JANUARY 13 23 JANUARY 13
- 24 JANUARY 13 30 JANUARY 13
- 31 JANUARY 13 JANUARY 31, 13
February:
- 1ST FEBRUARY 13 FEBRUARY 6, 13
- 7 FEBRUARY 13 FEBRUARY 13, 13
- 14 FEBRUARY 13 FEBRUARY 20, 13
- 21 FEBRUARY 13 FEBRUARY 27, 13
- 28 FEBRUARY 13 FEBRUARY 28, 13
November:
- 31 OCTOBER 13 NOVEMBER 6, 13
- 7 NOVEMBER 13 NOVEMBER 13, 13
- 14 NOVEMBER 13 NOVEMBER 20, 13
- 21 NOVEMBER 13 NOVEMBER 27, 13
- NOVEMBER 28, 13 4 DECEMBER 13
December:
- 1ST DECEMBER 13 DECEMBER 4, 13
- 5 DECEMBER 13 DECEMBER 11, 13
- 12 DECEMBER 13 18 DECEMBER 13
- 19 DECEMBER 13 DECEMBER 25, 13
- 26 DECEMBER 13 DECEMBER 31, 13
Why the "weeks" in November, have all 7 days, while the "weeks" in the first or the last week in the other month usually have less? (For example, February 28 is a 'week' alone.)
The following works for the other months:
WITH all_days AS
(
SELECT DATE "2013-01-01' + LEVEL - AS a_date 1
OF the double
CONNECT BY LEVEL<=>=>
)
SELECT DISTINCT
More GRAND (TRUNC (a_date + 4, 'IW') - 4)
, TRUNC (a_date, 'MONTH')
) AS week_begin
, The LEAST (TRUNC (a_date + 4, 'IW') + 2
TRUNC (LAST_DAY (a_date))
), Week_end
Of all_days
ORDER BY week_begin
;
Output:
WEEK_BEGIN WEEK_END
----------- -----------
January 1, 2013 January 2, 2013
January 3, 2013 January 9, 2013
January 10, 2013 January 16, 2013
January 17, 2013 January 23, 2013
January 24, 2013 January 30, 2013
January 31, 2013 January 31, 2013
February 1, 2013 February 6, 2013
February 7, 2013 February 13, 2013
February 14, 2013 February 20, 2013
February 21, 2013 February 27, 2013
February 28, 2013 February 28, 2013
...
November 1, 2013 November 6, 2013
November 7, 2013 November 13, 2013
November 14, 2013 November 20, 2013
November 21, 2013 November 27, 2013
November 28, 2013 November 30, 2013
December 1, 2013 December 4, 2013
December 5, 2013 December 11, 2013
December 12, 2013 December 18, 2013
December 19, 2013 December 25, 2013
26 December 2013 31 December 2013
-
sum of the months of data first weeks
1 January 09 5
January 2 09 3
January 3 09 2
:
:
:
1 February 09 1
February 2 09 1
February 3 09 1
4 February 09 1
5 February 09 1
6 February 09 1
February 7 09 1
For any date in January I should get the sum of the values of the next month first week i, e 1 February to 7 February 09 09
for example, 01 - jan - 09 = 7
:
:
29 jan - 09 = 7
It will be better if you give the query I have terms of
Sum (a) over (partition by order b by c lie between the interval Trunc (Trunc (sysdate, 'MONTH') + 1, 'MONTH') day following and '7' next day)Hello
When you use a DATE column, specify the RANGE as a number of days:
SELECT SUM (a) OVER ( PARTITION BY b ORDER BY c RANGE BETWEEN ADD_MONTHS (TRUNC (c, 'MM'), 1) - c FOLLOWING AND ADD_MONTHS (TRUNC (c, 'MM'), 1) + 6.99999 - c FOLLOWING -- Not 7, as origninally posted ) AS next_month_week_1_a
Published by: Frank Kulash, March 11, 2009 12:41
Fixed bug reported by Blushadow.
-
Is there a way just to have one or two applications, for example first pro cc or the two sequels. But I see LL is Photoshop for 9.99 per month, is there a way I can get just first pro cc only for 9.99 or something like that? I don't
# Photography is one of its kind special promotion. There is no other package prioritized at a similar discount. You can get single app or CC full plans.
Mylenium
-
How to get the Date in month based on week of the month.
Hi gurus,
I have provided.
Quarter (Q) = > 1 (Jan - Mar), 2 (April-June), 3 (July-September), 4 (October-December).
Months (M) = > Jan = 1, Feb = 2, Mar = 3 in the 1st quarter.
ARP = 1, may = 2, Jun = 3 in the 2nd quarter,
Jul = 1, August = 2, Ms = 3 in Q3,
Oct 1 Nov = = 2, Dec = 3 in the 4th quarter
If I give Q = 3, M = 3, W = 1 day = Fri so I get 6-Sep-13
Similarly, if I give Q = 2, M = 1, O = 3, day = game so I get 18 April 13.
Could someone help me higher and higher.
Concerning
Sanjeev
Believing that when you say you want to say that it is 1 - 5 in a month with the 1st day of the month as the beginning of the 1st week of the week. You can try this.
SQL > t
2 as
(3)
4. Select q 3, 3 m, 1 w, 'Ven' d
5 double
6 union
7 all the
8. Select q 2, 1 m, 3 w, d 'game '.
9 double
10)
11. Select q, m, w, d, d_day
12 years of)
13 select y + (level - 1) d_day
14, ceil (extract (day of cast (y + (level - 1) as timestamp)) / 7) week_7_day
15 , t.*
16 of)
17 select add_months (trunc (sysdate, 'year') (q * 3-3) +(m-1)) y
18 , t.*
19 t
20 ) t
21 connect
22 by level<= last_day(y)="" -="" y="" +="">=>
23 and prior y = y
dbms_random.value (24 and prior) is not null
25 )
where the 26 w = week_7_day
27 and substr (to_char (d_day 'day'), 1, 3) = lower (d);Q M W D D_DAY
---------- ---------- ---------- --- ---------
2 1 3 Friday 18 April 13
3 3 1 Fri 06-SEP-13SQL >
-
How to get the first day of the week on the calendar?
Hello
I'm storing calendar weeks in my database. for example 30/2013.
How can I get the first day of this week (Monday)? in this case, it is 22.07.2013
THX
Anja
with your_table as)
Select 30-2013' double your_column
)Select
trunc)
TO_DATE ("0101"
|| (substr (your_column,-4), 'MMDDYYYY'), 'IW')
+ to_number (substr (your_column, 1, 2)) * 7-7
start_of_week
from your_tableSTART_OF_WEEK 22/07/2013 Post edited by: chris227
Corrected example
Maybe you are looking for
-
HP 50 g: help a friend HP 50 G says he need map GB SD a1 by the Cal can find only 4 GB
Hello everyone, I have a friend in Saudi Arabia, who just bought a new HP 50 G, it is tring to find an SD card for it. He says he must have a 1 GB card, but I though it would use what is the maximum size, though i read before HP it wasn't size max th
-
Cannot display iTunes good screen
After downloading the last update... my iTunes screen is unusable It's as if the font size has been increased abnormally, album icons are very large... At the end of the mind with what to do Help, please!
-
Elite 8300 SFF: want to Samsung SSD AHCI instead of IDE can change?
Hello I replaced my HDD with a SSD, and when I run the Samsung software it say I should use AHCI instead of IDE.I found a place (Storage Options) in the bios where I can choose between IDE, RAID and AHCI.Is this the right place? Can I change IDE to A
-
Pavilion g6: HP Pavilion g series system disabled
When I start the system all of a sudden he asks me a password for administrator. I tried to guess the password and then it just says: System disabled with the following error code: 76207065 Please help, I need to solve this problem in all away today.
-
I use Windows XP (with Service Pack 3) and IE8. My goal is to be able to handle individual windows 'History' folder addresses as if each were a data file. Windows effectively extract individual addresses of the 'Historical' invisible system folder an