Calculate the Date of the next
HelloI have two dates:
Start date: December 18, 2007
End date: December 18, 2012
I would like to calculate the next payment date, using the example above, it would be December 18, 2010.
How can I achieve this in SQL by using the current date / month, keeping in mind, if sysdate is past the date, then the next payment date will follow month.
Thank you
Published by: sliderrules on December 15, 2010 08:50
Hello
Assuiming the due date is the same day of the month (if possible) as start_date:
SELECT start_date
, ADD_MONTHS ( start_date
, CEIL ( MONTHS_BETWEEN ( SYSDATE -- or maybe SYSDATE + 1
, start_date
)
)
) AS next_payment_date
FROM table_x
;
If you happen to run it on December 18, the expiry date should be December 18 or January 18?
The code above returns on 18 December. If you want Jnauary 18, replace SYSDATE SYSDATE + 1.
Assuiming that the due date is the same day of the month (if possible) as end_date, you could do something similar with the help of end_date.
Whatever it is, only one of the columns plays a role in this problem? What results would you if, for example. start_date was January 1, 2010 and July 20, 2012 end_date?
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and INSERT statements) and also publish outcomes from these data. For the results, after what you want if it was executed on 15 December 2010 at noon.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using.
Tags: Database
Similar Questions
-
After the installation of KB2582282, all timed SSRS 2008 subscription get the next bad performance calculated by the Scheduler SQL 2008. Is there any solution for this? I am running SSRS 2008 x 64 and SQL 2008 x 64 sp1. NO R2. After uninstalling the hotfix rollup16 for SQL, Scheduler calculates the next run correctly times again.
Hello
As the question you posted is related to Microsoft servers, I suggest you to ask your question to
Microsoft MSDN
SQL Server Reporting Services
http://social.msdn.Microsoft.com/forums/en-AU/sqlreportingservices/threads
-
PDF Acroform Javascript (WIN): Calculate the Date of next Tuesday
03/06/10
Greetings;
I found a javascript script that will calculate the date of next Tuesday, but I can't seem to make it work in Acrobat Pro v8 (Acroforms).
Any help / guidance you can provide is appreciated the most.
Script:
http://Christian.lassem.com/js/JavaScript-next-Tuesday/
JavaScript to find next Tuesday?
function find_date_of_next_tuesday() {}
var today = new Date();
today.setDate (today.getDate () + 1);
While (today.getDay ()! = 2) {}
today.setDate (today.getDate () + 1);
}
return (today.toDateString ());
}Thanks in advance.
You just need to call this function, and then use the string that it returns. What
does not work, exactly?
-
Calculate the number of days remaining until the next anniversary. Help, please!
Hi guys,.
I'm new to the forum and to the development of BB. So please do not judge harshly if the answer to my question seems obvious.
I need to calculate the number of days until the next birthday (taking into account any valid birth date)
After looking at the API and the forum search, I realized that I could
calculate the difference between two dates in milliseconds and then divide the delta of the value of a day in milliseconds. That is to say:
birthdayCalendar.set (Calendar.YEAR, those);
Date1 = birthdayCalendar.getTime () .getTime ();
date2 = System.currentTimeMillis ();
Delta = date1 - date2
numOfDays = delta\DateTimeUtilities.ONEDAY
Here's my question. How do I create a valid date1 what about leap years?
Maybe there's a better way to solve this problem?
Any help is greatly appreciated.
I agree that the determination of the number of days between today and Feb. 29 could be a little difficult, if it is not a leap year. I suspect that the calendar has a certain built-in mechanism to compensate for this, but your solution to choose a date is better.
DST has a role to play, and Yes, the calendar makes up for it. Let us take two dates, for example (before DST) March 1 and June 1 (after the DST). If you take a calendar and set the same hour, minute, etc., they are all the same except for dates, then subtract one from the other, and then divide by the number of milliseconds in 1 hour, you calculate the number of hours between the same time on two different days. You will find that it is not a multiple of 24 hours - because there is actually an hour less than the number of days since the clocks move forward (in the northern hemisphere anyway...),
In your case, you are not calculating the number of hours, you calculate the number of days. But you will be dividing by [24 * (time in an hour)]. If you take [23 * (time in an hour)] and divide it by [24 * (time in an hour)], using arithmetic on integers, you will end up 0. The easiest to get around this, who also works for the end of the DST too, is to simply add one hour to the date before the division.
Hope that makes sense...
-
How to calculate the difference between 2 dates, but with interruptions and stops between
Hello
How can I calculate the difference in minutes between 2 dates but taking into account the existence of a table in the Appendix, so if between start_date and end_date arguments, there is no 'work time' then this part of the time will not be included in the total difference.
Records of the time table example:
Time_configuration start_hour end_day end_hour 2 19:00 3 07:00 3 19:00 4 07:00 so for example first record said that on Monday you start at 19:00 and leave the next day at 7:00 and then save the same sort of thing.
There is an event that I want to track how many minutes lasted. for example, this event began the day 2 at 19:00 and ended the day 3 at 21:00
Theoretically, this event really lasted: 840 minutes. This 840 minutes are within the limits of the annex.
Thanks in advance.
The storage of the dates not as data type DATE in most cases is bad design. In addition, how do you know what day of the date is 2 at 19:00? East - Monday 2 November 2015 or Monday, March 7, 2016? It is the same for the event. In any case, assuming that both calendar and events don't extend over several weeks:
According to schedule)
Select time_configuration 2, 19:00 ' start_hour, end_day 3,' 07:00 ' end_hour of all the double union
Select 3, 19:00 ', 4,' 07:00 ' double
),
event like)
Select event_id 1, time_configuration 2, 19:00 ' start_hour, end_day 3: 21:00 ' end_hour of the double
)
Select e.event_id,
Sum)
less (e.end_day + to_date (e.end_hour, 'HH24'), s.end_day + to_date (s.end_hour, 'hh24:mi')).
greater (e.start_day + to_date (e.start_hour, 'HH24'), s.start_day + to_date (s.start_hour,'hh24:mi'))))
) * 24 * 60 minutes
Appendix s,
e event
where e.start_day + to_date(e.start_hour,'hh24:mi')< s.end_day="" +="">
and e.end_day + to_date(e.end_hour,'hh24:mi') > s.start_day + to_date(s.start_hour,'hh24:mi')
E.event_id group
/EVENT_ID MINUTES
---------- ----------
1 840SQL >
SY.
-
Calculate the date of the first or last in a quarter
Hello
I have data of project with a start date and end date I need to calculate the number of days per quarter
project x: 15/03/06 - 15/05/06
15 days Q1 = Q2 = 45 days
I'm then going to calculate the percentages of resource. I can get the bt of the watch with a hack of a time to identify the first or the last day of a given quarter. Any help win my sincere admiration.
Sorry, misread the question. The district will rely on the company that you work for. If the end of his is the same as an end of year calendar (31 December), then the example below will be accurate. Change the dates according to the needs of the company.
You can hardcode the variables in your application.cfm page.
quarter1start = "01 - jan -";
quarter2start = '01 - apr -';
quarter3start = "01 - jul -";
quarter4start = '01 - oct -';Programatically, the end of each quarter is always the day before the start of the next quarter.
I would add "year" to the equation dynamically, to keep in it before compatible. -
How to store data in slot - VI for the next race
Hello
I read a file csv and data read from the file in the form of tables (about 170000 pieces). I'm processing the data in a Subvi. Several times, I call the Subvi main VI treatment. Because it takes a lot of time to read the file each time. I'm storing the berries in local variables and when I call the Subvi next time, I read the data in local variable instead of reading the file. This reduced the manyfolds execution time. Since the applocation doesn't face crisis of memory right now, I don't deal with any problem. But I don't know what happens when the application is running on the system with less RAM. Will be the local variable be deallocated (which makes it unusable applications), or he will throw all memory error?
Is there an other way better to store data in slot - VI that can be used the next time when it is called (without all the main data VI)?
Hi Laurent,.
See the attached screenshot of LV help for the effectiveness of the memory of the different elements of pass-through of LV
-
Hello
In my App, I need to display the next 14 days Dates of the current day.
How can I get then 14 dates?
I am able to get the current date.
Thanks in advance.
Bingo!
Earlier, I tried the same thing and its working very well.
1 day = 86400000 millis
long currentTime = System.currentTimeMillis(); currentTime += 86400000; // for 14 times
-
request to get the next date which is not a public holiday
Hello world
I need help for a query. consider the following data
holiday
-------------
SELECT To_Date('12/28/2015','mm/dd/yyyy') double holiday
UNION ALL
SELECT To_Date('12/25/2015','mm/dd/yyyy') double holiday
UNION ALL
SELECT To_Date('08/31/2015','mm/dd/yyyy') double holiday
UNION ALL
SELECT To_Date('05/25/2015','mm/dd/yyyy') double holiday
UNION ALL
SELECT To_Date('05/04/2015','mm/dd/yyyy') double holiday
curr_DATE
-----------
SELECT To_Date('12/25/2015','mm/dd/yyyy') double holiday
UNION ALL
SELECT To_Date('12/24/2015','mm/dd/yyyy') double holiday
UNION ALL
SELECT To_Date('12/23/2015','mm/dd/yyyy') double holiday
data of curr_date are the main table. given a date, I want to join the vacation and the date of the Curr so that the result will be a date that is not a holiday. for example, what gives 28 Dec. the next available in curr_date < 28 dec date is dec 25. However, dec25th is a holiday on the guest table if the output should be dec 24.
Another example is the following: given dec 25 date, the previous date, unless that Dec. 25 is dec 24th dec 24 is not in the host table output should therefore be dec 24.
Another example: I'll add another line to the curr_date table. If the data will look like this
curr_DATE
-----------
SELECT To_Date('12/28/2015','mm/dd/yyyy') double holiday
UNION ALL
SELECT To_Date('12/25/2015','mm/dd/yyyy') double holiday
UNION ALL
SELECT To_Date('12/24/2015','mm/dd/yyyy') double holiday
UNION ALL
SELECT To_Date('12/23/2015','mm/dd/yyyy') double holiday
given dec 29, the next available in curr_date date is less than 29 dec 28 dec. However, dec28th is holiday in the host table. the next available date is dec 25 in curr_date, but once again dec25 in the host table. the next available date is 24, but this date is not in the host table output should therefore be 24/12/2015.
So basically I want to do this in the query by joining the two tables. can anyone help? pl/sql is ok if it cannot be done using quries.
Hello
If you want to use a join, here's one way:
SELECT MAX (c.holiday) AS last_non_holiday
OF curr_date c
LEFT OUTER JOIN holiday h ON h.holiday = c.holiday
WHERE c.holiday< to_date="" (:cutoff_date,="">
AND h.holiday IS NULL
;
-
. For example, I need to calculate the difference between a date column, 'Table_Name '. "' Column_Name ' and (Current_Date-1). I tried different ways to do this. But nothing seems to work.
Try the below formula.
Replace "Time". "" Date "with your column.
TIMESTAMPDIFF (SQL_TSI_DAY, "Time". "Date", TIMESTAMPADD (SQL_TSI_DAY-1, CURRENT_DATE))
Thank you!
-
How to calculate the periods that overlap between two or more given the date range?
Hi all
If there are several durations then how we can calculate the period of time that overlap between these times.
For example: for 3 time periods. 03/12/2015-16/08/2015, 05/01/2015 to 31/07/2015 and the 06/09/2015 to 30/11/2015, how the overlap period can be calculated?
There are many potential unknowns in your question. For example, you want to count any overlap at all? If two dates overlap, what matters? Overlap - each of them?
In any case, here is a solution that counts how many periods are overlapping in any point in time... She, of course, using temporal logic. You can then use ValueAt(), WhenLast(), WhenNext(), etc. as appropriate.
Assume that your model has a child entity called 'the period' with name 'all time periods' relationship and basic attributes 'start date of the period of time' and 'date of end of period of time'.
In your example:
an entity should have the time period start date = 03/12/2015 and the date of end of period of time = 16/08/2015
another entity might have the time period start date = 01/05/2015 and the date of end of period of time = 31/07/2015
another entity might have the time period start date = 06/09/2015 and the date of end of period of time = 30/11/2015
To find the number of overlapping over time, we want to count or entities that have an active period, so the rule is perhaps the sum:
the number of overlapping = the number of all the periods for which it is true that the time period is active
How do we know a time is active? This is the time logic comes in. He is active on or after the start date or no later than the end date:
the time period is active if
TemporalOnOrAfter (the date of beginning of period of time) and
TemporalOnOrBefore (date of end of period of time)
That's all. Now, you can perform a temporal visualization of the 'number of overlapping' and you'll see it rise and fall over time. As a reference, he said that the number of overlapping = 3.0 from 06/09/2015 across 31/07/2015.
I hope this helps. You can use the same model to count periods of time functions, but you end up having to use the most logical date. You of course can count the total number of entities and compare this number of overlap over time to see if they overlap, but I digress...
-
Choosing a date, then to have this date fill in the next two weeks.
I have a form that has a start date, put end to date fields then 14 representing the next 14 days. I wish that she either auto fill all fields when you choose a date. For example, if I choose the start date of 01/01/2016 then the end date would be auto complete to 14/01/2016 then each field day below that would have filled in with 01/03/2016...01/14/2016 01/01/2016, 02/01/2016.
Currently, I have date pickers for each field and it works fine just painful.
Thanks for any help.
You should read these tutorials:
https://acrobatusers.com/tutorials/working-with-date-and-time-in-Acrobat-JavaScript
https://acrobatusers.com/tutorials/working-with-date-and-time-in-Acrobat-JavaScript-part-2
https://acrobatusers.com/tutorials/working-with-date-and-time-in-Acrobat-JavaScript-part-3
Basically, the process is to use a custom calculation script to read the date entered, string to convert to a Date (using the util.scand method) object, to add X days (using the setDate method) and then print the new date (using the util.printd method).
If you are interested in a tool that will allow you to easily configure without writing code, check out this, I developed exactly for this purpose a while ago: Scripts custom Adobe: Acrobat - automatic Date calculation applies
-
How can I save a form so that the input data are visible. When I click on the cell, I can see what has been entered, but when I go to the next cell, the data is hidden again. I would like to print the file with the visible information that has already been entered.
To clarify what mentioned TSN, forms PDF that are used and saved by the application on a Mac are corrupt in a number of ways. When a form that has been corrupted by the Preview is opened in Acrobat/Reader, one of the symptoms is exactly what you describe. If you have access to Acrobat and the original form, empty, not corrupted, you can export the form data in a data file (e.g., FDF) and import the shape of FDF data in the blank form.
-
Filter to display the end date in the next 30 days
Hello
In OBIEE 11 g I have an attribute for the date of end of contract, how can I filter to show only the contract which will end only in the next 30 days - I need a filter to have like SQL
Assuming that your LC End Date is indexed, you can get much better performance if you create a filter LC end date and place it between two Expressions, SQL: current_date AND TIMESTAMPADD (SQL_TSI_DAY, + 30, current_date)
-
PDF possessing blocks to fill in dates, how do you get in the next box?
I have a pdf form that has separate blocks to enter the date. How do the next block? I can type in the first, but it won't let me tab or click on the next block.
The field type you describe is called a "Comb" field Prior to version 6, there was no option for the field that could take the entire string of data at once and then display them with each character in a box.
Have you tried to enter the entire field data as a single string?
Would it be possible that the designer does not properly create the form field.
Can you provide a link to a sample of the form you are trying to fill?
Maybe you are looking for
-
Satellite Pro L20 - RAM runs with low speed
Dear reader, I've recently updated my Toshiba Satellite Pro L20 to 2 GB, DDR2 667 mhz (Corsair ValueSelect) RAM because the old 512 MB of ram would not cut it anymore with all these processes.Now, when I check my speed of ram with CPU - Z it says 200
-
HP Officejet 6700: cannot connect wireless
Msg wireless configuration: locked by the administrator or a person who setup of printer
-
Device Consumer IR - (code 31)
Hi there I turned off my dell studio laptop last night when I went to turn this morning that it only would not start nothing worked and more running in SafeMode with network I looked everywhere on how to solve this problem and learned it's Consumer I
-
How can I restore completely without disc or administrator password
I bought a laptop computer at a friend's House. There is an administrator password that no one can remember. How to restore factory? It has Vista program.
-
Tamron VC 24-70 Lensprofile unavailable?
HelloI can't select the lensprofile of my Tamron 24-70.He selects the Tamron 28-75 puts, when I try to select the 24-70, I only have the option for the 28-75 (no other Tamron lens available).As far as I know that the correct lensprofile should be ava