Date of the first and the last of the week
I have a date that isdates week_no
---------------- -----------------
1 JULY 09 ' 26
I want to take the first and the last date of the week in which my date (1 July 09 ') exists, this means
I want to catch the first date of the 26th week and the last date of the 26th week.
Not sure what is your first day of the week, but in any case, you can change
SQL> select dt, trunc(dt,'iw') monday, trunc(dt,'iw') + 6 sunday from (
select date '2009-07-01' dt from dual
)
/
DT MONDAY SUNDAY
---------- ---------- ----------
01.07 2009 29.06 2009 05.07 2009
Tags: Database
Similar Questions
-
the start date of the week formula
Hi guys,.
I have a report in which I need to display the Start Date of the week for a particular calendar date, for example
Date week Start Date
---------- ---------------------------
July 01, 2010 June 28, 2010
July 2010 05 05 July, 2010
11 July, 2010 05 July, 2010
No idea how can achieve us.
Thank you
RonnieTIMESTAMPADD (SQL_TSI_DAY, 2, TIMESTAMPADD (SQL_TSI_DAY, DAYOFWEEK (CURRENT_DATE) *-1, CURRENT_DATE))
-
RPD required Variable: first day/date of the week
Hi all
As a requirement, I need to create a repository variable that would show the first day of everyweek. In other words, I need to display the date on the Monday of each week.
Could if it you please let me know how this is possible.
Thank you
RonnyHello
Good to see that you help.
If you find this helpful please be free to assign some points...Concerning
Nicolae -
wants to get the dates of the week
Hi guys,.
I want the weeks when I give the nth week number.
But when I give it 1 or 2 inplace 21st I do not get the results.Eg: SQL> select to_date(to_char(sysdate,'iw'),'DD'),to_date(to_char(sysdate,'iw')+6,'DD')from dual 2 where to_char(sysdate,'iw') =21 3 ; TO_DATE(T TO_DATE(T --------- --------- 21-MAY-12 27-MAY-12
OK I can without restricting my sysdate...?
Thans
Published by: san on May 24, 2012 17:04Select trunc (sysdate, 'yyyy') + (& week * 7)-6, trunc (sysdate, 'yyyy') + (& week * 7) double
-
Restart or read courses at first and not last page
We have a course with a questionnaire which must be passed.
If the user does not pass must relaunch the course in order to randomize the quiz questions. We noticed that the course is the reopening last police page.
\is there a way to force a project to open ONLY on the first page anywhere - off left? I realize that this would be unnecessary if the user also left having to start
I think this is a job for a table of contents page, but can't think how
help appreciated
It is a SCORM file to load on an LMS, you must check the 'Never resume data' option under the Advanced button in the reports dialog box:
If it is not transferred to an LMS, and you use the table of contents and biscuits or local storage for bookmarking, you will need to uncheck learning self-paced option in the parameters of the table of contents. But this option is cancelled by the LMS functionality if you publish a LMS.
-
Date of the Monday of the week and year
Hi gurus,
I have the data for the week (eg.52) and year (eg. 08) and I need to get the date of the Monday of the week (December 21, 2008... IE 52nd week of 2008.)
Pls know me the solution for this sql statement...
Thank you
Shashi...Hi, Shashi,
user588757 wrote:
Hi gurus,I have the data for the week (eg.52) and year (eg. 08) and I need to get the date of the Monday of the week (December 21, 2008... IE 52nd week of 2008.)
Pls know me the solution for this sql statement...
Thank you
Shashi...Surely you meant December 22, 2008, No 21.
Assuming that you are talking about ISO dates, where week 1 starts the Monday closest to January 1:TRUNC ( TO_DATE ( :year_txt , 'YYYY' ) , 'IY' ) + (7 * (:week_val - 1))
where: year_txt is a string and: week_val is a number.
TRUNC (dt, "IY") is attached to the Monday of the week 1.
-
change the dates of the new person-
Hi all
Someone gave me a m130 and the date of the week begins on Monday, the software on the computer, it begins Sunday (that's what I want on the palm pilot). All of the suggestions.
Thank you
Norm
Hello and welcome to the Community Forums of Palm.
To change the starting day of the week from Monday to Sunday, go to the prefs application. Select the Formats in the drop-down list at the top right. The second to the last item of the list, it's week begins, where you can select either Sunday or Monday.
Message relates to: None
-
Hi friends,
I have the below query that returns me the data as below:
Select 'Label', to_number (to_char (to_date(start_date,'yyyy-mm-dd'), 'IW')) - to_number (to_char (add_months (sysdate,-6), 'IW')) + 1 as a weekly sum, (col1) val yyy_view
where to_date(start_dt,'yyyy-mm-dd') between trunc (add_months(sysdate,-6)) and trunc (sysdate)
Group of to_char (to_date(start_date,'yyyy-mm-dd'), 'IW')
order of to_char (to_date(start_date,'yyyy-mm-dd'), 'IW')
Label weekly val
1 20 data
2 24 data
3 20 data
4 28 data
5 20 data
6 24 data
and so on...
Now the requirement is to get the last date of the week for each week as below
Label weekly val
given 2011-08-30 20
given 2011-08-23 24
given 2011-08-16 20
given 28 2011-08-09
given 2011-08-02 20
the weekly column should have the date of the last week. In the example above Wednesday is supposed to be the last date of the week.
Kind regards
PradeepMissed the part "Wednesday is considered date of last week. The week is Thursday to Wednesday. If so:
select 'Label', trunc(min(start_dt)) as day2, sum(col1 ) val from yyy_view where start_dt between trunc(add_months(sysdate,-6)) and trunc(sysdate) group by trunc(start_date - 3,'IW') order by trunc(start_date - 3,'IW') /
SY.
-
How to get the date of Sunday of the week
Hello
I have a column date 'start_date', I need to create a report for all the weeks from Sunday, for example:
I need to get the dates of the week in the form:
mm/dd/aa-23/01/11, 01/16/11, 09/01/11 and so on...
Help, please
Thank you...Hello
To find the last Sunday before or equal to start_date:
SELECT TRUNC ( start_date + 1 , 'IW' ) - 1 AS week_start_date ...
You can also use an expression like that in a GROUP BY clause.
It's not you NLS parameters. Always ISO weeks start on Monday. Your week begins 1 day earlier, that is why the above expression is the + 1 and -1.
(According to the parameters of the NLS)SELECT TRUNC ( start_date , 'D' ) AS week_start_date ...
could do the same thing, but I still have rocommend with "IW"; a few extra touches is not big thing to pay for a guarantee that it will still work.)
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and INSERT statements) and the results desired from these data. -
Hello
I wrote a query to get a weekly report, which is expected to start a week from Sunday to Saturday typical. for example, the week is 03/04/2011 to 04/09/2011 I run the query or the task on Word to say about any of the week of 10/04/2011, 04.11.2011 etc... Here's my query, but it seems to work of the sysdate to-7 days that does not receive the Sunday to Sam requirement... someone can you please...
Select uid, psn, TO_char(date_in,'mm/dd/yyyy')
OF THE TEST
WHERE the uid like '% % ST.
and date_in > trunc (sysdate)-7
ORDER BY date_in CSA;
Thank you.If you want that data for the week previous ? In if so then just tweak the settings a bit:
SELECT uid , psn , TO_char(date_in,'mm/dd/yyyy') FROM test WHERE uid LIKE '%ST%' AND date_in >= TRUNC(SYSDATE,'IW') - 8 AND date_in < TRUNC(SYSDATE,'IW') - 1 ORDER BY date_in ASC ;
-
selection of the week, month, year in source throgh odi 11g?
Hello
I have 3 years of data in a source table (tableatm). data will be added to this table eod.
I applied the filter on the column atm_date below screenshot
Based on the filter, I want to load the data of the year underway, data of the current month data of the week underway, data from the previous month, data from the previous week, data from the previous year to this table.
If I want to load data for 2010, then filter applied on TO_CHAR (TABLEATM. ATM_DATE, 'YYYY') = '2010' , I get only the data of 2010.
If want to download data from 2015, filter applied on TO_CHAR (TABLEATM. ATM_DATE, 'YYYY') = "2015". But it's constant...
I want to give the filter like that.
TO_CHAR (TABLEATM. (ATM_DATE, «YYYY») = double '(sélectionnez (sysdate,-12)) ". When I applied the filter using this formula on this date column. I don't get all the data.
Please help me...
Please help me,
Thanks in advance,
A.Kavya.
Hello
I applied the dynamic filter as shown below. now, I get only the data of the year 2015...
filter condition is
TO_CHAR (to_number (to_char (TABLEATM. ATM_DATE, "YYYY"))) = (SELECT to_char (to_number (to_char (SYSDATE, 'YYYY'))-1)
THE DOUBLE)
Thanks & regards,
A.Kavya.
-
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
-
To display the first and last date of one month
I have the date format in 10 Mar 10.
My requirement is when ever I select the date in the dashboard for all the month it should show results of all the months.
I had the request for obiee101.blogspot.com.but if I use that sometimes it is not the latest results of the day. Any body please give me the query to display the results for the first day and lastday?
I select any day from the drop-down menu of the guest, it must display the month of ex: if results
If I select either 1 mar mar 10.2 10,30 mar 10...
It should give results for the month of March.
Can you please provide me the query for the last month also?
If I select March date date print want to display the results of March together in a single column, results of the previous months in the other column
Someone help me to achieve this?Yes, you are right. Jean SQL for the last day of the month, if the "last day of the previous month" ends on June 30, that "adding a month" will result in the 30th of the following month. But if the next month has 31 days, you don't miss this day here.
Use it for the last day of the current month.
TIMESTAMPADD (SQL_TSI_DAY-1, TIMESTAMPADD (SQL_TSI_MONTH, 1, TIMESTAMPADD (SQL_TSI_DAY, 1, TIMESTAMPADD (SQL_TSI_DAY, DAYOFMONTH (CURRENT_DATE) *-1, CURRENT_DATE))))
The SQL above will ensure that you will get always the last day of the month "current" no matter how many days during the previous or current month.
-
Extract the first and the last Date of the previous month
This seems to be a delicate but again it is perhaps easy for some of you people.
Here is how I find the previous month
Any ideas on how to get the first and last date of the previous month?
Thanks in advance.Hello!
SQL> SQL> select last_day(add_months(sysdate,-1)) from dual; LAST_DAY -------- 28.02.10 SQL> select trunc(add_months(sysdate,-1),'MM') from dual TRUNC(AD -------- 01.02.10 SQL>
T
-
Need a query to return the first and last date for a rowset.
Hello
I have a query which can be simplified to the following data, if
Assume that it is my dataset, with THE_VALUE of
Sign (Anum) therefore,-1, 0 or 1.
* (Sorry for crushed registration. "I can't understand this website's rich text formatting.) *
THE_VALUE THE_DATE THE_MEMBER
1 0 1 January 2007
1 0 1 February 2007
1 0 1 March 2007
1. 1 April 1, 2007
1 1 1 May 2007
1 0 1 June 2007
1. 1 July 1, 2007
1. 1 August 1, 2007
1 0 01 - sep - 2007
2 0 1 January 2007
2 1 February 1, 2007
2 0 1 March 2007
2. 1 April 1, 2007
2 1 1 May 2007
2 0 1 June 2007
-2 1 1 July 2007
2. 1 August 1, 2007
2. 1 01-sep-2007
3 0 1 January 2007
3. 1 February 1, 2007
3 0 1 March 2007
3 0 1 April 2007
3. 1 May 1, 2007
3 0 1 June 2007
3. 1 July 1, 2007
3. 1 August 1, 2007
3 0 01 - sep - 2007
I need to get the lines with the THE_MEMBER, the values of the first and the last
THE_DATE, where the value is - 1, and the date range is the last
set of lines to the Member, with the same value of THE_VALUE.
I tried the following to get the dates of first and last for a set
consecutive months with the same value for the Member.
SELECT the_member
the_value
the_date
first_value (the_date)
in the first_date (PARTITION the_member, ORDER BY the_member the_value, the_date)
last_value (the_date)
during the last_date (PARTITION the_member, ORDER BY the_member the_value, the_date)
OF togola
ORDER BY the_member
the_date;
At first, it seems to work, but then, when the return value
an old value, FIRST_DATE will be the first of all the lines containing
This value for the Member rather than the first of consecutive
rows with this value for the Member. Apparently the partitioning
occurs before the order.
THE_MEMBER THE_VALUE THE_DATE FIRST DATE LAST DATE
1 0 January 1, 2007 January 1, 2007 January 1, 2007
1 0 1 February 2007 1 January 2007 1 February 2007
1 0 1 March 2007 1 January 2007 March 1, 2007
1. 1 April 1, 2007 April 1, 2007 April 1, 2007
1. 1 May 1, 2007 April 1, 2007 may 1, 2007
1-0 June 1, 2007 January 1, 2007 June 1, 2007
1. 1 July 1, 2007 April 1, 2007 July 1, 2007
1. 1 August 1, 2007 April 1, 2007 August 1, 2007
1 0 01 - sep - 2007 1 January 2007 01-Sep-2007
2 0 January 1, 2007 January 1, 2007 January 1, 2007
2 1 1 February 2007 February 1, 2007 February 1, 2007
2 0 1 March 2007 1 January 2007 March 1, 2007
2. 1 April 1, 2007 February 1, 2007 April 1, 2007
2 1 1 May 2007 February 1, 2007 may 1, 2007
2-0 June 1, 2007 January 1, 2007 June 1, 2007
-2 1 1 July 2007 February 1, 2007 July 1, 2007
2. 1 August 1, 2007 February 1, 2007 August 1, 2007
2. 1 01-sep-2007 1 February 2007 01-Sep-2007
3 0 January 1, 2007 January 1, 2007 January 1, 2007
3. 1 February 1, 2007 February 1, 2007 February 1, 2007
3 0 1 March 2007 1 January 2007 March 1, 2007
3 0 April 1, 2007 January 1, 2007 April 1, 2007
3. 1 May 1, 2007 February 1, 2007 may 1, 2007
3 0 June 1, 2007 January 1, 2007 June 1, 2007
3. 1 July 1, 2007 February 1, 2007 July 1, 2007
3. 1 August 1, 2007 February 1, 2007 August 1, 2007
3 0 01 - sep - 2007 1 January 2007 01-Sep-2007
That's what I need to get in the end.
THE_MEMBER FIRST DAY DATE OF LAST
July 2 1 2007-01 - Sep - 2007
Any ideas would be really appreciated.
Published by: user10700981 on December 17, 2008 13:57Hello
We'll call the lines whose the_value =-1 'good' lines and lines with the_value! =-1 ranks of 'bad '.
For each value of the_value, we need the first and last values of the_date where
the last row in the group is good
(b) the current line is good
(c) there is a lot of lines from the current line to the end of the Group
Condition (a) is just a special case of (c).
Conditions (b) and (c) are similar: (b) if applied to the current line, (c) applies to all lines after him. They can easily be combined into a single test that counts the number of lines after the current line or bad.Which produces the results you requested of the sample data that you provided:
WITH count_bad AS ( SELECT the_member , the_date , COUNT ( CASE WHEN the_value != -1 -- assuming the_value is never NULL THEN 1 END ) OVER ( PARTITION BY the_member ORDER BY the_date DESC ) AS bad_cnt FROM table_x ) SELECT the_member , MIN (the_date) AS first_date , MAX (the_date) AS last_date FROM count_bad WHERE bad_cnt = 0 GROUP BY the_member ORDER BY the_member;
Maybe you are looking for
-
I have problems to install iTune 12.5.1.21 on my windows 10 64-bit Desktop. I downloaded the latest version of 64-bit, but still a problem. I am inserting an image of the error massage because it's too long to type.
-
My Apple TV 1st generation can not access my Apple ID iCloud account
Hello! New problem. Now, when I want to connect my Apple TV 1st generation to my iCloud account, or when I want to rent a movie from my account iCloud for display on my TV, after that I entered my * correct Apple ID & pswd on Apple TV, I get on my iP
-
GTX 980 TI still does not work
I bought a GTX 980 TI knowing that I probably would feed the 6 and 8 pins externally. I thought it would work at least to normal loads while I built a more elegant solution. No dice. The machine just clicks and dies. I got a new PSU ATX modular power
-
Partition on HARD drive disappeared after formatting using the product recovery disc
My laptop came with a partitioned hard drive C and D drives. After formatting my hard drive using the recovery disk of the supplied product with my computer, I don't have any option to partition the HARD drive, only for the 1. 46 GB for some recommen
-
Well reinstall Windows Vista - MAJOR problem...
For not giving all my cleaning stuff correctly a system, but I need help with something that makes me really mad. It's about Vista and something weird with the file system. I service computers to save his life, im pretty well informed and have tried