Function to retrieve the first day of the month.
Select (sysdate, 'IW') of doubleI know it takes the date of Monday. Is there a function like above that has the date of return to the first Monday of the month?
Thanks in advance.
Hello
NEXT_DAY is very convenient, but it is dependent on the NLS_DATE_LANGUAGE, and you cannot pass an argument to override that.
TRUNC (dt, 'IW') is not in the NLS settings, then you may prefer this:
TRUNC ( 6 + TRUNC (SYSDATE, 'MONTH')
, 'IW'
) AS first_monday
1st Monday of the month is fixed to the Monday or before the 7th of the month.
Tags: Database
Similar Questions
-
Hello
Can someone help me to write a code when a random day is given a month, that the day should change automatically
in the first day of a month.Can you give an example?
Do you mean the last day of the month for a random date?
Then you can simply use builltin Oracle LAST_DAY function:SQL> select sysdate from dual 2 union 3 select last_day(sysdate) from dual; SYSDATE ------------------- 03-05-2012 18:17:04 31-05-2012 18:17:04
-
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
-
GetWindowLongPtr function to retrieve the handle to application
Hello world
I used the following line to get the handle to the window of my windProc application
HINSTANCE appHandle = GetWindowLongPtr (hWnd, GWLP_HINSTANCE);
promptly, which returned an error saying that "a long value cannot be used to initialize an entity of type HINSTANCE. But when I used the word HINSTANCE as return type, it ends up being fine.
HINSTANCE appHandle = (HINSTANCE) GetWindowLongPtr (hWnd, GWLP_HINSTANCE);
I know that the return value is changed when I do this. But I'm curious to know why I have to do exclusively. HINSTANCE is not a long_ptr type? In fact the same thing happened earlier when I tried to assign the function of GetStockBrush to app.hbrBackground. He obliged to specify the return type as HBRUSH.
This issue is beyond the scope of this site (for consumers) and to be sure, you get the best (and fastest) reply, we have to ask either on Technet (for IT Pro) or MSDN (for developers)* -
Oracle function to retrieve the records randomly
I need function to select a random DB folder.
For example, we have 500 records and an input to the function value is 5 ways, it must display the records randomly between 1 to 5
Thank you
Question is not clear, I thought that Oracle has always returned entries in random order... Do you expect the number of records between 1 & 5?
Kind regards
-
First day of the month between 08:00 and 18:30
DB version: 10.2.0.4
Due to the nature of our the first working day of each month (like today 1 MS), the DB will be very busy.
We execute a proc purge planned Windows Scheduler every 5 minutes every day.
But the first day of every month (like today 1 MS), if it's a day of the week (Monday to Friday) we do not want this proc running between 08:00 and for dinner from 18:30.
So, I thought including the logic in the procedure itself.
How can I implement this?
Edited by: user872043, Sep 1 2010 08:48Here is an example of using DBMS_SCHEDULER which should meet your needs:
Create schedules
BEGIN DBMS_SCHEDULER.CREATE_SCHEDULE ( schedule_name => 'every_5_schedule' , repeat_interval => 'FREQ=MINUTELY; BYMONTHDAY=2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31; INTERVAL=5; BYSECOND=0' , comments => 'Schedule to run every 5 minutes' ); DBMS_SCHEDULER.CREATE_SCHEDULE ( schedule_name => 'busy_hourly_schedule' , repeat_interval => 'FREQ=MINUTELY; BYMONTHDAY=1; BYHOUR=0,1,2,3,4,5,6,7,19,20,21,22,23; INTERVAL=5;' , comments => 'Schedule to run every 5 minutes except certain hours on the first of the month' ); DBMS_SCHEDULER.CREATE_SCHEDULE ( schedule_name => 'busy_6pm_schedule' , repeat_interval => 'FREQ=MINUTELY; BYMONTHDAY=1; BYHOUR=18; BYMINUTE=30,35,40,45,50,55' , comments => 'Schedule to run every 5 minutes from 6:30 - 7' ); END; /
There are three lists.
every_5_schedule - runs every 5 minutes for all the days that are not on the first day of the month
busy_hourly_schedule - runs every 5 minutes for the acceptable hours on the first day of the month
busy_6pm_schedule - retrieves the half hour from 6:30 - 7 on the first day of the month.Then, create your business:
Job creation
BEGIN DBMS_SCHEDULER.CREATE_JOB ( job_name => 'YOUR JOB' , job_type => 'PLSQL_BLOCK' , job_action =>'BEGIN YOURPROC; END;' , repeat_interval => 'EVERY_5_SCHEDULE, BUSY_HOURLY_SCHEDULE, BUSY_6PM_SCHEDULE' , enabled => TRUE , comments => 'Some comments' ); END; /
HTH!
-
Retrieves the name of the variable
Hello
I'm trying to change the OpenG changed? Subvi (see below) so that he will write the new value of the variable sent to 'Variant' if changed on the disk (using the following config VI). To do this, I need to somehow extract the variable name of the variable (any type) which was connected to the entrance of variant of the changed? Sub - VI by VI calling so that I can use it as a key name. Is this possible? This information is still transmitted to the Subvi?
If you use openg, there is a "Get the name of data" function that retrieves the name of the data passed in the Variant.
-
How to retrieve the name of the partition of a deployment process
Hello
In a 11g BPEL process I need the partition name (for example - default etc.) in which the process has been deployed. As we buld available function to retrieve the instance id (ora:getCompositeInstanceId ()), we have no function to retrieve the name of the partition?Hello
Try this to affect the business.
Kind regards
Neeraj Sehgal -
I have created a form with 2 date objects:
"Date1" is a date object in which the user will enter the first day of a month gave "MM/DD/YYYY";
I need "Date2" to calculate the last day of the month of 'Date1' ' MM/DD/YYYY ".
Obviously, the date displayed in Date2 will vary, because months contain a different number of days, so I can't just say '+ 30 '. Can someone help me with a JavaScript for the FomCalc code to achieve this?
Thank you!!!
Gene-O
Maybe you're view model is different from the trend in the script.
Here is an example of work form:
-
Function to retrieve all the days of the previous month.
Hello
Yes, it's a monthly report, I received the task at hand.
So, all I need is every day of the previous month (even if there is no data for that day)
I was instructed to use the following code, but it does not return a value any:
-----DECLARE CURSOR CUR_LAST_DAY IS SELECT TO_CHAR (LAST_DAY (ADD_MONTHS (SYSDATE, -1) ), 'DD') FROM DUAL; VVA_LAST_DAY VARCHAR2 (2); -- VNU_JOUR NUMBER := 0; BEGIN OPEN CUR_LAST_DAY; FETCH CUR_LAST_DAY INTO VVA_LAST_DAY; CLOSE CUR_LAST_DAY; WHILE VNU_JOUR <= TO_NUMBER (VVA_LAST_DAY) - 1 LOOP VNU_JOUR := VNU_JOUR + 1; END LOOP; END; --CLOSE CUR_LAST_DAY --DEALLOCATE CUR_LAST_DAY
On the other end, I developed this code:
Which returns a null value. :(SELECT TO_CHAR(SYSDATE,'dd') FROM DUAL WHERE TO_CHAR(SYSDATE,'dd') >= to_char(to_date(to_char(ADD_MONTHS(SYSDATE, -1),'yyyy-mm')||'-01'),'yyyy-mm-dd') AND TO_CHAR(SYSDATE,'dd') < to_char(LAST_DAY(to_date(to_date(to_char(ADD_MONTHS(SYSDATE, -1),'yyyy-mm')||'-01'),'yyyy-mm-dd')));
ConcerningHello
You want to retrieve whole days of the month last query... So here's...SELECT TO_DATE(LEVEL||'-'||TO_CHAR(ADD_MONTHS(SYSDATE,-1),'MON-YY'),'DD-MON-YY') COMP_DATE, TO_CHAR(TO_DATE(LEVEL||'-'||TO_CHAR(ADD_MONTHS(SYSDATE,-1),'MON-YY'),'DD-MON-YY'),'DD') ONLY_DD, TO_CHAR(TO_DATE(LEVEL||'-'||TO_CHAR(ADD_MONTHS(SYSDATE,-1),'MON-YY'),'DD-MON-YY'),'MM') ONLY_MM, TO_CHAR(TO_DATE(LEVEL||'-'||TO_CHAR(ADD_MONTHS(SYSDATE,-1),'MON-YY'),'DD-MON-YY'),'YY') ONLY_YY FROM DUAL CONNECT BY LEVEL <= TO_NUMBER(TO_CHAR(LAST_DAY(ADD_MONTHS(SYSDATE,-1)),'DD'))
I'm not at the machine database so not tested.
But one thing do not forget that this forum only for reports, it is a separate SQL and pl/sql instance.
Function to retrieve all the days of the previous month.-Clément
Published by: Graham on April 22, 2010 22:53
Spelling error -
First day with the mobile and shatter proof - broken
Hello
I bought Xperia double Z3, mobile is great and every thing,
In the first day of use, it fell out of my hand on the ground, I picked up there instantly, but I was surprised that the screen was kicked as he was struck by the big hammer!
the functionality of contact has been lost, I went back to the buyer, and he told me that the warranty covers accidents, I told him that I had samsung s4 for two years and it is fell 100 times and harder than that and there was no damage at all to the screen!They said that the screen was not shock resistant break proof!
I send the local support of sony in Egypt and they replied "good luck with your repair!
How can a mobile screen get bashed like that from a simple fall, and what is the problem with people taking in charge of sony?
Someone knows how to climb to a higher level of support?
If there is, please share the link, there is no such thing as a "phone shatter proof". I'm sorry about your question, but you have 2 options, 1. with your Xperia local as Jean-Claude suggested or DIY 2, for the last dated, you will cancel your warranty, but it might be cheaper, just to buy the LCD screen online and follow this
http://www.Xperiablog.NET/2014/09/30/Xperia-Z3-disassembly-Guide/
-
PL/SQL function to calculate the non-working days
Hello
I have the following pl/sql function which generates a number of days between two selected dates (i.e. excluding weekends). However, I also need to exclude specific holidays - day of Christmas etc. These holiday dates are stored in a table in our database (11 GR 2) called "HOLIDAY".
How can I integrate the holidays which is held in the table of holidays in the following query to exclude these dates as well? I know how to write a separate funtion pl/sql for a number of days between two dates using SELECT... BUT I can't work out how to bring together them in a single query.
Could someone show me how with the pl/sql / dates below please?
Example of HOLIDAY table below.
Thank you!
TP
create or replace function WORKING_DAYS (pi_start_date in date, pi_end_date in date) return integer is v_start_date date :=pi_start_date; v_end_date date:=pi_end_date; v_count integer:=0; begin while v_start_date <= v_end_date loop if to_char(v_start_date,'D') not in ('6','7') then v_count := v_count+1; end if; v_start_date:=v_start_date+1; end loop; return v_count; end;
(select '10-Apr-2013' as NWD from dual union all select '06-May-2013' from dual union all select '27-May-2013' from dual union all select '26-Aug-2013' from dual union all select '26-Dec-2013' from dual union all select '25-Dec-2013' from dual union all select '01-Jan-2014' from dual union all select '18-Apr-2014' from dual union all select '21-Apr-2014' from dual union all select '05-May-2014' from dual union all select '26-May-2014' from dual union all select '25-Aug-2014' from dual union all select '25-Dec-2014' from dual union all select '26-Dec-2014' from dual) HOLIDAYS
Hello
the link is on MOSC, not OTN... Here's a copy:
This function calculates the number of days between two dates, ignoring weekends and holidays (if requested and if the holidays are stored in a table)
I give an example of table 'public_holiday' with sample data, but users must ensure that their table contains the relevant data (all holidays within the maximum range of use of the service)
CREATE TABLE public_holiday (calendar_day, DATE, text VARCHAR2 (30));
FUNCTION to CREATE or REPLACE nb_days (p_date_from IN DATE
p_date_to DATE by DEFAULT TRUNC (sysdate)
, p_public_holidays in CHAR DEFAULT 'Y '.
) RETURN NUMBER
DEFINE AUTHID
AS
/*********************************************************************/
/ * Author: Bruno Vroman * /.
/ * Created: 23-AUG-2012 * /.
/ * Last updated: 23-AUG-2012 * /.
/ * Object: to calculate the number of days between 2 dates, to the exclusion of * /.
/ * Saturday and Sunday, but also "holidays" If the * /.
/ * argument 'p_public_holidays' = 'Y ' * /.
/ * Support: p_date_from<= p_date_to ="">=>
/ * component ' hour min dry "ignored (just counting days) * /.
/* First step: */
/ * the calendar days between 2 days * /.
/ Remove 2 days for each "week" and 0 or 1 extra day * /.
/ * function to a condition "complex" mix day of first week * /.
/ * and the number of days when full remaining weeks are removed * /.
/ * (set up once for all, for example if there is 3 days and the * /)
(/ * first day is a Thursday, there is 1 "Sat/Sun" to subtract) * /.
/ * Second step: If 'p_public_holidays' = 'Y': other * /.
/ * days, do not count holidays. */
/ Holiday everyday are defined in a table "public_holiday" * /.
/ * Note: there may be holidays defined on Saturday/Sunday. */
/*********************************************************************/
l_result NUMBER;
l_from DATE;
l_to DATE;
l_case tank (4);
BEGIN
l_from: = TRUNC (p_date_from);
l_to: = TRUNC (p_date_to);
l_case: = TO_CHAR (l_from, 'Dy', 'NLS_DATE_LANGUAGE = English').
To_char (MOD (l_to - l_from + 1, 7));
l_result: = l_to - l_from + 1
-TRUNC ((l_to-l_from + 1) / 7) * 2
-CASE
WHEN l_case IN ('Mon6', 'Tue5', 'Wed4', 'Thu3', 'Fri2'
, "Sat1", "Sun1", "Sun2', 'Sun3", "Sun4".
, "Sun5', 'Sun6.
)
THEN 1
WHEN l_case IN ('Tue6', 'Wed5', 'Wed6', 'Thu4', "Thu5"
, 'Thu6', 'Fri3', 'Fri4', 'Fri5', 'Fri6 '.
, "Sat2", "Sat3', 'Sat4', 'Sat5", "Sat6.
)
THEN 2
0 OTHERWISE
END
;
IF SUPERIOR (p_public_holidays) = "Y".
THEN
SELECT l_result - COUNT (*)
IN l_result
OF public_holiday p
WHERE p.calendar_day > = l_from
AND p.calendar_day<=>=>
AND SUBSTR (TO_CHAR (p.calendar_day
, "Dy".
'NLS_DATE_LANGUAGE = English'
)
, 1, 1 ) != 'S'
;
END IF;
RETURN l_result;
EXCEPTION
WHILE OTHERS
THEN
DBMS_OUTPUT. Put_line (' CTF nb_days (' |))
To_char (p_date_from, "MON-DD-YYYY"). ', ' ||
To_char (p_date_to, "MON-DD-YYYY"). ', ' ||
p_public_holidays | ' ) : ' || SQLERRM
);
LIFT;
END nb_days;
/
REM
REM example:
REM A) fill out the 'public_holidays '.
REM
TRUNCATE TABLE public_holiday;
INSERT INTO public_holiday VALUES (DATE ' 2012-01-01', ' new year (a Sunday)');
INSERT INTO public_holiday VALUES (DATE '' 2012-01-03, "for example");
REM (insert other days...)
COMMIT;
Call the function for some pairs of dates of REM B)
REM nb1: remove only Sat/Sun
REM nb2: also remove holidays
REM
ALTER SESSION SET nls_date_format ='Dy DD-MON-YY';
WITH some_dates AS
(SELECT DATE ' 2011-12-29'd dual FROM
UNION ALL SELECT DATE ' 2012-01-08' FROM dual
UNION ALL SELECT DATE ' 2012-01-10' FROM dual
)
SELECT d1.d 'FROM '.
, d2.d ' to THE '.
, nb_days (d1.d, d2.d, ' don't) nb1
, nb_days (d1.d, d2.d, 'Y') nb2
OF some_dates d1
some_dates d2
WHERE d1.d<=>=>
ORDER BY nb1, nb2, d1.d
;
GO TO NB1 NB2
------------- ------------- ---- ----
Monday, January 8, 12 Monday, January 8, 12 0 0
Friday, December 29, 11 Friday, December 29, 11 1 1
Wednesday, January 10, 12 Wednesday, January 10, 12 1 1
Monday, January 8, 12 Wednesday, January 10, 12 2 2
Friday, December 29, 11 Monday, January 8, 12 7 6
Friday, December 29, 11 Wednesday, January 10, 12 9 8
Hope that this could be useful, but note that this code has not been completely tested, so check and test before you trust it (in the case of any questions, please post a comment)
Bruno Vroman.
Best regards
Bruno
-
Function to return the number of days in a month?
In one of my rules, I need to allocate an amount of benefits based on the number of days remaining in the calendar month.
OPM does have a function that can provide me with the number of days in a calendar month?
Thank you very much
IsamuIt is not a direct function to do this, however, it can be done with a bit of messing around. The following rules you will get the number of days of the month of the date of the date
Basically, you get the first day of the month, add a month to the first day of the following month and then get the number of days between them, which will give you the number of days of the month of the date
the month = ExtractMonth(the date) the year = ExtractYear(the date) the start of the month =MakeDate(the year, the month, 1) the start of the next month = AddMonths(the start of the month, 1) The number of days in the month = DayDifference(the start of the month, the start of the next month)
These rules can be a little more compact, but it is basically how to do it.
-
Retrieve the name of the function call
I have 2 function in the CFC, even calling another function in the same CFC.
IS anyway to get the name of the first function (the appellants) from the second?
OR
is there anyway inside a function to retrieve this name?Sounds right up your alley:
-
find the first day of the month
Hello...
can u pls let me know how to find the first day of the month, if the number of months (for ex - OCT-10) is passed as input
Kind regardsI'm not sure that there is a function called FIRST_DAY().
SQL> SELECT first_day (SYSDATE) 2 FROM DUAL; SELECT first_day (SYSDATE) * ERROR at line 1: ORA-00904: "FIRST_DAY": invalid identifier SQL> SELECT TRUNC (SYSDATE, 'month') 2 FROM DUAL; TRUNC(SYS --------- 01-DEC-08 SQL>
I hope this helps.
Kind regards
Joice
Maybe you are looking for
-
the iPod line out 5 or 6.
I connect a portable headphone amp to an iPod 6 and want to use ie lightning plug jack 3.5 mm output line. Is there anything as they all seem to be 30-pin for iPod 4?
-
Satellite U500 freeze after installing the Nvidia display driver
I just did a clean install of Windows 7 Professional 64 bit on my machine and tried to install the drivers from the Toshiba site. However, after the installation of the driver and restarted, the l' ordinateur computer seems to be ok for a few seconds
-
importing CDs is not possible; error message: not found medium
Hello with the following facilities, I'm not able to import/convert audio CD into my iTunes mediathek: iTunes 12.3.2.25 MacOS: 10.11.3 He has worked in the past with no problems... Thanks and greetings
-
The cd and the packaging looks authentic
-
Then BB run android lve wallpaper?
BB support android live wallpaper now? When porting android live wallpaper for bb, he isn't complaining, don't know if he can really run on the device real bb, on the Simulator, it cannot work.