SQL to generate the last weeks date (not a stored procedure)
I need SQL to generate the last dates of weeks from Monday to Sunday. I don't want to use the data in the table or the stored procedure. I need inline SQL. Please help me with your suggestions. Thanks in advance for the help.Varun says:
I need SQL to generate the last dates of weeks from Monday to Sunday. I don't want to use the data in the table or the stored procedure. I need inline SQL. Please help me with your suggestions. Thanks in advance for the help.
below should help you get started
1* SELECT SYSDATE-LEVEL from dual CONNECT BY LEVEL < 8
SQL> /
SYSDATE-L
---------
21-APR-13
20-APR-13
19-APR-13
18-APR-13
17-APR-13
16-APR-13
15-APR-13
7 rows selected.
Tags: Database
Similar Questions
-
SQL to generate the intervals from date of 6 months each, between two date ranges
Hi all
I looked in the forums, if someone uses CREATE_CHUNKS_BY_SQL for dates, but no luck.
I want to update a table using pieces of dates.
I need to generate date ranges to divide them by pieces.
I have a table where I know that max (sales_date) and min (sales_date).
Lets say max (sales_date): min (sales_date) 01/01/2008: 31/10/2010
I want to break in intervals of 6 months (180 days) as below:
He didn't exactly finish end of the month. Basically, I need these beaches of dates at apart 180 days.chunk_id start_date end_date -------- ---------- -------- 1 01/01/2008 06/30/2008 2 01/07/2008 12/31/2008 3 01/01/2009 06/30/2009 4 01/07/2009 12/31/2009 5 01/01/2010 06/30/2010 6 01/07/2010 10/31/2010
I appreciate if someone can throw some ideas on this.
Thank you
Raj.Hi, Raj,
Sorry, it is unclear what you are asking.
To generate a list of dates starting with min_sales_date and including all the 180 days after that up to (but not beyond) max_sales_date:
WITH got_params AS ( SELECT DATE '2008-01-01' AS min_sales_date , DATE '2010-10-31' AS max_sales_date FROM dual ) SELECT min_sales_date + (180 * (LEVEL - 1)) AS grp_start_date FROM got_params CONNECT BY LEVEL <= CEIL ( ( (max_sales_date - min_sales_date) + 1 ) / 180 ) ;
Output:
GRP_START_D ----------- 01-Jan-2008 29-Jun-2008 26-Dec-2008 24-Jun-2009 21-Dec-2009 19-Jun-2010
December 16, 2010 is 180 days after June 19, 2010, but it is not displayed, because is after max_sales_date, which is 31 October 2010.
I hope this helps you.
Whenever you have any questions, post a small example of data (CREATE TABLE and INSERT statements) and the results desired from these data. -
Calculate the last week of work
Hello
I use Oracle Database 11.2.1 and have a query that needs to filter on the date range of the last week of work. This must ignore Sat/Sun and works only on the days from Monday to Friday.
If I just use sysdate - 7 this will include weekends, can anyone suggest a better solution to take into account only the last work week (Monday to Friday)Hello
sliderrules wrote:
... If I just use sysdate - 7 this will include weekends, can anyone suggest a better solution to take into account only the last work week (Monday to Friday)So, if you run the query on Wednesday, May 15, you want that he only dates Monday, may 6 to Friday, may 10, inclusive; Isn't it?
If so:
WHERE dt >= TRUNC (SYSDATE, 'IW') - 7 -- 1 week ago Monday AND dt < TRUNC (SYSDATE, 'IW') - 2 -- the Saturday after thar
"Before Saturday' is identical to ' until and including Friday.
This is not your NLS settings.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.
Since the output depends on the time of execution, after a couple of different run times and results you want to obtain the same sample for each run-time data.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum {message identifier: = 9360002} -
marking of documents created in the last week with the word 'NEW '.
Hi all.
I have a mysql database with a table 'articles' containing the following (and other) fields:
- category_name
- Date_Created
- level_name
- title
- Summary
I have set up a query to extract information on the statutes of the db. The questioning of basic works very well. It looks like this:
$r = @mysqli_query ($dbc, $q);
/ * display the results * /.
If ($r) {}
while ($row = mysqli_fetch_array ($r, MYSQLI_ASSOC)) {}
echo "< div class ="derniers_articles"> < strong class >: < facilities >". "." $row ["category_name"]. ' < br / > < strong > < em > posted on: < facilities > '. $row ["date_created"]. ' < br / > < level >: < facilities > '. $row ["level_name"]. "< /em > < h3 > '. $row ["title"]. "< / h3 > < class p ="last_ten"> < em >. $row ["Summary"]. ' < /em > < /p > < / div > ';
}
mysqli_free_result ($r);
} else {}
echo "< p > Prob get the info you need." < /p > ';
}
The query gives me result like this:
Category: News
Posted the: 2011-02-10 22:58:05
Level: 5, 6Are you interested in politics?
There are too many young people who don't is interested not in politics. It's a secret United Nations pay no one. However, this isn't the case of Darcy Lonergan who, at 21 years old, the youngest is launching itself candidates who pour win a seat in the next Parliament.
Now, I want to mark all records created in the last week with the word 'NEW' so I inserted the line in bold in the following code:
$r = @mysqli_query ($dbc, $q);
/ * display the results * /.
If ($r) {}
While ($row = mysqli_fetch_array ($r, MYSQLI_ASSOC)) {}
echo "< div class ="derniers_articles"> < strong class >: < facilities >". "." $row ["category_name"];
If (DATE_SUB (CURDATE (), 7 DAYS INTERVAL < = DATE($row['date_created']))) echo "< strong > NEW < facilities > ';"
echo "< br / > < strong > < em > posted on: < facilities > '." $row ["date_created"]. ' < br / > < level >: < facilities > '. $row ["level_name"]. "< /em > < h3 > '. $row ["title"]. "< / h3 > < class p ="last_ten"> < em >. $row ["Summary"]. ' < /em > < /p > < / div > ';
}
mysqli_free_result ($r);
} else {}
echo "< p > Prob get the info you need." < /p > ';
}
.. but he throws this error:
Parse error: syntax error, unexpected T_LNUMBER in [file path] on line 31
31 is the "BOLD" line, I inserted. Can someone tell me what I am doing wrong? ("The date_created field is a timestamp like this ' 2011-01-08 18:06:39 '.)
I'm new to php so be nice!...
Thanks in advance.
Hugh
I think I'd be inclined to do in the query.
By example SELECT field1, Field2, field3, etc, IF (DATEDIFF (NOW (), dtCreated)< 7,="" 'new',="" '')="" as="" recordstatus="" from="">
Then echo just the value of the recordStatus for each record.
-
For the last week or three Firefox updates two or three times for each update. Sometimes it refreshes without obvious reason. For example, I'll be in the middle of typing in the message forum block & it refreshes. Or by filling out an online form. Or simply viewing a page.
You can check for problems caused by an extension that is not working properly.
Start Firefox in Safe Mode to check if one of the extensions (Firefox/tools > Modules > Extensions) or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox/tools > Modules > appearance).
- Do NOT click on the reset button on the startup window Mode without failure.
-
Message: My windows Movie Maker has stopped working in the last week.
Message: My windows stopped filmmaker working within the last week, began when the error message "the collections of file is not valid or is damaged. A new empty collections file has been created. When I try and import a file of any image type or otherwise, the file is not imported and the error message ends with "unknown error."
So far WMM worked without fault, as full support has been removed for XP I am now unable to get all the patches. There is also no file conversion to allow to allow the import of files. Times, error message "class not registered"?
What I'd really like is a copy of WMM version 5.1 (Build 2600 xpsp_sp3_gdr.101209 - 1647: Service Pack 3) Windows Movie Maker Version 2.1. 4028 0, I would continue with WMM, but am completely reluctant to upgrade to Windows 7. Someone at - he found a solution for the problem that I am facing.If you can open Movie Maker... try to go to... Tools / Options /.
Compatibility on the left tab, click on the "all default settings"
button / OK.Also... Do a restore of the system in Mode safe for a time
before the problem started, may be worth a try.See the following articles:
(306084) how to restore Windows XP to a
previous state
http://support.Microsoft.com/?kbid=306084How to restore a Windows XP system
a previous state using system restore
http://bertk.MVPs.org/(315222) a Description of the Safe Mode
Boot into Windows XP options
http://support.Microsoft.com/?kbid=315222How to start safe mode in Windows XP
http://bertk.MVPs.org/html/SafeMode.htmlGood luck...
-
XPS 15 much warmer than usual, running for the last week
I have a XPS 15 laptop with SSD drive and plenty of RAM which usually remains cool. Last weekend he installed an update of Windows 10 (I think it was the version 1607). Since then the fan worked upstairs while the laptop is turned on and it feels warmer than usual. The CPU load can be less than 20% for an extended period, but the fan continues to run. I managed to go back to the previous version of Windows and it has not changed.
The only thing that worked partly is to limit the maximum level of the CPU at 50% (I tried to use this setting on the battery and then unplugged the laptop). This cut the fan at a lower level, but I never had to do before. So far, the fan would rarely work at all.
What is going on? Do we need updated drivers?
It's very strange. I was watching the new to-do Manager trying to figure out why it's so hot when the CPU load is 20%. Upstairs, he said Intel Core... @ 2.2 GHz. On the right, it indicates the maximum speed: 2.2 GHz. On the left, he said speed: 2.9 GHz (sometimes going up to 2.8).
If I put the State of maximum CPU at 99%, it falls down to 2,18 GHz, if I put it at 100% it goes back up to 2.9 GHz. I don't remember what he showed before it started, but this sounds very wrong. In both cases it is going above 2 GHz, even if the processor is not much used, but I guess it's ok if it is not overheating. It is already cooled down in a few minutes and I'm waiting to see if the fan breaks down.
Apparently he did this during the last week and a half. What happens here? Dell release a updated driver overclocked my CPU?
-
How to calculate this column (the last week of the month)?
I have a request where it shows a few months of calculations of sage
ex. This report is for Dec-2010
statement line. A reduced rate. Approved rate. Last week declined the rate |
-------------------------
Asia report | ------20%----- | -----45%-------- | --------4%------ |
Africa report | ------44% -----| -----21%-------- | ------12%-------|
I'm figuring the column rate declined last week . The logic is simply not coming to my mind.
Can someone suggest me how can I calculate this?We'll see. This report at any time after the previous month running has closed...
(1) TIMESTAMPADD (SQL_TSI_DAY, (DayOfMonth (CURRENT_DATE)) *-1, CURRENT_DATE) will give you the last day of the previous month.
(2) TIMESTAMPADD (SQL_TSI_DAY, DAYOFWEEK (TIMESTAMPADD (SQL_TSI_DAY, (DayOfMonth (CURRENT_DATE)) *-1, CURRENT_DATE)) *-1, TIMESTAMPADD (SQL_TSI_DAY, (DayOfMonth (CURRENT_DATE)) *-1, CURRENT_DATE)) will give you the Saturday before the last week of the month.
(3) TIMESTAMPADD (SQL_TSI_DAY, 1, TIMESTAMPADD (SQL_TSI_DAY, DAYOFWEEK (TIMESTAMPADD (SQL_TSI_DAY, (DayOfMonth (CURRENT_DATE)) *-1, CURRENT_DATE)) *-1, TIMESTAMPADD (SQL_TSI_DAY, (DayOfMonth (CURRENT_DATE)) *-1, CURRENT_DATE))) will give you the Sunday of the last week of the previous month.
Now that you have the start of the last day of the previous week, you can create your filter... It will be "(between 3) and 1)" above... "
-
HOW remove 'directionsAce' by myway of Chrome... it changed my home page and I can't get RID of it! There is NO sign of it in the Applications, nor of any 'addition' what anyone new in the last week. He hides.
I worked all morning with directions from the web... and so far nothing has helped.
Thank you
It seems that you might have downloaded some malware or adware. Download Malwarebytes Anti-Malware for Mac to get rid of him. In the future, avoid the following types of sites to prevent it happening again:
- XXX sites
- torrent sites
- Group download sites (CNET, Softonic, download (dot) com, MacUpdate, etc..)
- MP3 download sites (Mp3 Skull, mp3monkey, etc.)
- No matter what website says you can do or download something for free you know otherwise you would cost money
-
The last backup was not completed
After the 9.2.1 update. When I try to backup to icloud I get. The last backup could not be completed. I have 4.3 GB left on icloud and backup on 300megabites, tried to restore, configured as new restored new ipad ios and the same. Finally, I created a new apple ID and it works, I have the same on my mini ipad apple ID 4 and it works but iphone 5s wil not after the update, it has always worked before so should be a problem with the apple, contacted support ID and they are supposd to return to me, anyone else have this problem and hot to solve , can I save on itunes OK but not icloud
KIL
I read in other threads that it is a known issue with Apple and they are working on fixing. It happened to me also. I'm backup in iTunes in the meantime.
-
I transferred my pictures from my camera to my mac, and they downloaded with the only place wherever they appear in "the last download" but not in "events". I also downloaded on my macbook and had the same response. I've never had this problem before and have tried everything. How can I get them to appear in the "events"? Since my last camera download, I have create a second library, but they are not more in the events.
CTRL-click a picture on the last import, then select "Show event. It shows the event?
-
For the last week or so my app on my iPhone revel want updated. What's new?
For the last week or so my app on my iPhone revel want updated. What's new?
We solved that question revel iOS upgrade. Please see the details at:
-
Space in the store of data not released when a virtual machine is removed
Hey all,.
I have a game fairly simple up - two servers ESXi 2 Terminal servers. I'll have a problem, but with space in the store of data not be released on one of them after that I got a clone to the virtual machine, made my changes and removed the original. I can find no record anywhere, using vSphere (not in the inventory or when I browse the data store), but the HARD drive space using the server is still assigned somewhere.
Any body have tips on where to find or how to fix this if it is indeed a problem?
Any help is greatly appreciated.
Thank you.
How bout refreshing your data store? tab Configuration-> storage-> refresh?
vcbMC - 1.0.6 Beta
Lite vcbMC - 1.0.7
-
Extract the last opening date of session using Groovy?
Is it possible to extract the last opening date of session of the user via a Groovy script? I went through the scheme, but I don't have the slightest idea how to begin to know where there.
Ideally, I'd end up with a list that displays the name of each user connection and date of last connection.
Try this:
msg = new StringWriter()
SS = server. SecurityService;
FMS = server. HaMembershipService.getHostName)
Msg. Append ("FMS; Foglight ID; Foglight roles; lastLogonTS; logonCount; statusDesc; logonType; createdTS\n')
(user) {ss.findAllUsers ()}
Msg. Append (FMS). Append(";")
Msg. Append (User.Name). Append(";")
List =]
for (secRole in ss.getAllRolesForUser (user.name)) {list += secRole.name}
Msg. Append("["). Append (List.Join(",")). Append("];")
Msg. Append (User.lastLogonTS.ToString ()). Append(";")
Msg. Append (User.logonCount.ToString ()). Append(";")
Msg. Append (User.getStatusDesc ()). Append(";")
If (User.isExternal ()) {msg.append ("external ;")}
Else {Msg.Append ("Internal ;")} ")}
Msg. Append (User.createdTS.ToString ()). Append ("\n")
}
return msg;
-
Why did the last updated do not and give me U44M1P7 this_?
See above. Why did the last updated do not and give me U44M1P7 this_?
Hi cfosofart,
Please go follow the mentioned kb: http://helpx.adobe.com/creative-suite/kb/error-u44m1p7-installing-updates-ccm.html .
Kind regards
Romit Sinha
Maybe you are looking for
-
IDT audio driver for Windows XP
Hello I have a DV7-1050ef downgraded to XP. I know that HP does not support Windows XP more. Anyone found yet an IDT audio driver for Windows XP? I have already tried many, none of them worked. I also installed the UAA kb888111.exe driver. Do I need
-
Toshiba L 39 4333 software freeze
Hello very often when I turn on my TV, loading software freeze 90%, in this case is impossible to change the language, to load the menu or do anyting but to change the channel or volume. Switch off tv does not solve the problem, the only solution is
-
I liquidated my bar. As the search bar when you type in the web address, and now I can get it back. I handed to the clicked place where I did to trun off (unchecked it), and I don't see anything again?
-
Whenever I type the letter t in an email, Firefox leads me to an empty search page
Whenever I type the letter t in an email, Firefox leads me to an empty search page This has happened Each time Firefox opened Is whenever I type the letter t
-
How copying (moving, transfer) one hard drive to another (not old pc to new pc