Number of days since 31/12/1979 converting a date value?
Hi all
I'm not an expert in oracle sql and I hope that someone could help me. A column of a table is titled BHS_KDTE_SEQU. This column has 111616 lines and the values stored in these areas are the number of days since 31/12/1979.
When I write a select statement, how can I convert to get the date value since 31/12/1979 instead of the number of days?
Thank you in advance!
Hello
f429ff94-4133-48E0-AE1C-afcb148d3c2f wrote:
Hi all
I'm not an expert in oracle sql and I hope that someone could help me. A column in a table is called BHS_KDTE_SEQU. This column has 111616 lines and the values stored in these areas are the number of days since 31/12/1979.
When I write a select statement, how can I convert to get the date value since 31/12/1979 instead of the number of days?
Thank you in advance!
Then
1 means January 1, 1980,
2 means January 2, 1980,
...
31 January 31, 1980, means
32 means February 1, 1980.
...
366 means December 1, 1980,
367 means January 1, 1981,
and so on?
Here's one way:
SELECT DATE ' 1979-12-31' + bhs_kdte_sequ AS dt
TABLE;
When you add a DATE d and a NUMBER n in Oracle, the result is the DATE n days after days.
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and INSERT statements) and the exact results you want from these data.
Check out the Forum FAQ: Re: 2. How can I ask a question on the forums?
Tags: Database
Similar Questions
-
Compare and get the number of days since the same date field
Hello
I need to get the results in days when comparing the same field, date
For example,.
Primary_key_field Date_field
100000002 1 January 10
100000004 February 1st, 10
100000005 30 April 10
100000006 April 18, 10
100000007 29 April 10
100000008 May 1st, 10
extract the first two date_field records based on the primary_key_field. (January 1, 2010 and February 1, 2010) and compare and find the difference and who appear in number of days, the same fetch two disks and do the same math... How can I achieve this... is it possible to make the SQL thro? Please help me solve this problem...
Thank you and best regards,
KBG.This is the query using functions oracle Analytics
Primary_key_field Date_field
100000002 1 January 10
100000004 February 1st, 10
100000005 30 April 10
100000006 April 18, 10
100000007 29 April 10
100000008 May 1st, 10Select rn, date_field, next, next - date_field "Diff".
de)
ROW_NUMBER() SELECT over (ORDER BY primary_key_field) rn,
date_field, LEAD (date_field) OVER (ORDER BY date_field) next
FROM table_name)
/ -
SQL to count the number of days of January with a range of dates
I have data like this, how to calculate the number of days with January in this date range.
BEGINNING END DAYS OF JAN 12/12/2013 20/01/2014 20 21/01/2014 02/02/2014 11 Hello
So, you want to count the number of days between
(a) either start_dt, or January 1, 2014 (prevailing later) and
(b) or end_dt or January 31, 2014 (whichever comes first).
However, if start_dt and end_dt are prior to January 2014 (or both are later) which will result in a number negative if you take the difference or 0, if it is higher.
This looks like a job for the GREATER and LESS than functions.
SELECT start_dt - START is not a column name good
, end_dt - is neither END
BIGGER (1 + LESS (end_dt, DATE ' 2014-01-31'))
-Most GREAT (start_dt, DATE '' 2014-01-01)
* v
) AS jan_days
FROM table_x
;
If you would care to post CREATE TABLE and INSERT instructions for some examples of data, then I could test it.
-
Number of days between two objects Oracle.jbo.domain.Date
I have two objects Oracle.job.domain.Date:
Date = StartDate (Date) CurrentRow.getAttribute ("StartDt");
Date = CurrentDate (Date) this.getOADBTransaction () .getCurrentDBDate ();
I want to find the number of days between StartDate and CurrentDate.
I tried the CompareTo () function, but its does not not the desired results.
Can someone let me know how I can find the number of days between StartDate and CurrentDate above?
Concerning
HawkerHawker,
Use the code below
Date StartDate= (Date)CurrentRow.getAttribute("StartDate"); Date CurrentDate = (Date)am.getOADBTransaction().getCurrentDBDate(); java.sql.Date sdate = (java.sql.Date) StartDate.dateValue(); java.sql.Date cdate = (java.sql.Date) CurrentDate.dateValue(); int days = daysBetween(sdate,cdate ); public int daysBetween(java.sql.Date d1, java.sql.Date d2){ return (int)( (d2.getTime() - d1.getTime()) / (1000 * 60 * 60 * 24)); }
Kind regards
GYANPublished by: Gyan on 27 March 2011 19:56
-
convert the date value in column 1 help
Am on 10g.
I have a column: STAMP_DATE with these values:
I leave the INHERITANCE, as it is, but everything else, I need to convert to the: MMYYYY as in: 092010 for example.
9 sep means so seven-2009. The number is the year, I am trying to solve this problem.
Any SQL help would be appreciated, thanks!
STAMP_DATE
"LEGACY".
"9-sep.
'9 - Oct'
'9 - Nov'
"" 9-may
'9 - Mar'
"9 - Jun"
"9 July".
'9 - Dec'
"9-Aug.
"April 9.
'10-May '.
'10 - Mar'
'10-jan.
'10 Feb.
"" 10 Apr
These values were imported from Excel using SQLLDR, so he made them a bit like that.with s as
(select 9 - Sep' double jnk)
Union
Select ' 9 - APR ' double jnk
)
Select to_char (to_date(jnk||) (("e - 01 ', ' AA-MON-DD '), 'DD-MM-YYYY') s
/Seems to be working at home time tonight.
-------------
Sybrand Bakker
Senior Oracle DBA -
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...
-
Count the number of days of previous instance entity
Hello
My context, global and one of many relationship which is a list of contracts.
I think I can explain my problem with an example:
Contract 1:
Start date: 01/01/2013
End date: 31/03/2013
2 contract:
Start date: 05/01/2013
End date: 31/08/2013
Contract 3:
Start date: 11/01/2013
End date: 31/03/2014
I want to do this:
For contract 3, calculate the number of days for contract 1 + contract 2 + 3 contract
For the market 2, calculate the number of days for the 2 + 3 on contract market
To contract 1, calculete number of days for contract 1
Moreover, I would calculate the number of days limited to 28 months before the date of the end of each contract.
For contract 3 calculate the number of days until the 31/03/2014 but on 30/11/2011.
Means that
-If a contract of 4 ends before 30/11/2011-> not taken
-If a contract of 4 begins on 11/01/2011 and ends on 15/12/2011, the days of the 12/01/2011 to 15/12/2012 are taken into account.
For contract 2 calculate the number of days until the 31/08/2013, but since 30/04/2011.
Means that
-If a contract of 4 ends before 30/11/2011-> not taken
-If a contract of 4 begins on 11/01/2011 and ends 15/12/2011-> not taken
Hope my explanation is clear.
I don't know how mixt:
temporal reasoning
reasoning of entities
through the reasoning of entities
as
-for a contract, I have to see all deals before and not one after (cross entities reasoning)
-I have to count a number of days, but if there is a period without a contract that I have to ignore days (temporal reasoning)
Then I am quite lost.
If anyone can help me in this situation aprehendate the appropriate.
Thank you.
Hey guys I think I found the solution, here my idea in french (sorry my client is franco-french):
the contract if course of est en
Temporelencoursouapres (contract start date)
and
TemporelEnCoursOuAvant (date of end of contract)
a contract is being so
Exists (employment of the applicant, the contract is ongoing)
the value of the number of days to count pour the contract to determine the last date of end of contract to take into account
0
TemporelAvant (InstancesMinimum (employment of the applicant, the start date of the contract))
0
TemporelAvant (the start date of the contract to determine the last date of end of contract to take into account)
0
Temporelapres (InstancesMaximum (employment of the applicant, the end date of the contract))
0
Temporelapres (date of end of contract)
0
Temporelapres (the end date of the contract to determine the last date of end of contract to take into account)
3
the day is the last day of February
and
Temporelencoursouapres (the start date of the contract to determine the last date of end of contract to take into account)
and
a contract is underway
1
No (the day is the last day of February)
and
Temporelencoursouapres (the start date of the contract to determine the last date of end of contract to take into account)
and
a contract is underway
0
otherwise
the value of the number of days through contracts pour prescribe the last contract end date to take into account = Temporeldatedepuisdebut (all jobs of the applicant, the date (the number of months to be taken into account for the period affiliation) months before the end date of the contract, the value of the number of days from paying the contract to determine the last date of end of contract to take into account)
the duration of contracts from pour prescribe the last contract end date to take into account = IntervalleSommeQuotidienne (the start date of the contract to determine the last date of end of contract to be taken into account; AddDays (InstancesMaximum (employment of the applicant, the end date of the contract) 1); the value of the number of days through contracts pour prescribe the latest end date of contract to take into account)
-
Current Date more number of days script
Hi all
I have a form that I'm building that has a date field (currently Setup to specify the date of today on the load). There is a field that slects number of days until a billing cycle (currently 0 in 13 days).
I need to set up a script that takes today's date, adds the number of days since the result of 0-13 and gives a result of a date (0-13 days from today for example).
Any thoughts on how I could do this? Very new to JS.
Thanks for any help you may be able to provide.
Ant
Here is an example of what I used:
var f = this.getField ("BILLINGCYCLEDATE");
G1 var = this.getField ("DAYS");
var g = g1.value
var today = new Date();
Add var = d1.valueOf ();
Add += 1000 * 60 * 60 * 24 g,
future var = new Date (add);
f.Value = util.printd ("mm/dd/yyyy", future);
You do not want to set up as a calculation in your field BILLINGCYCLEDATE. Field DAYS, that's all that you configured as the counter 0-13. I implemented a simple text box where you enter a number. The field will then calculate X number of days. I hope this helps.
-
Is it possible to do it in a table? (Count the number of days from a certain date)
Hello
I did yesterday a data base to make my job easier. I could make it even more effective if I could understand this delicate piece of business.
What I have is in my table has a column called "Date completed". This column contains the date when the project was completed. Then, I would like to have another column in the table called "number of days elapsed since completion. This column would have simply taken the date in column "Date completed" and count the number of days since that day and show them in a numeric value (i.e. 28). This way I could do a select and display everything is over for a number of days where I need complete my report (s).
Thanks for any help. If you know a way to do that is completely different from what I'm trying to please do not hesitate to propose a solution, I'm a complete newbie to this. I took a basic SQL course at the College a few years ago, but never learned to do anything as advanced as this.
Thanks againYour number of days can be easily calculated as trunc (sysdate) - date you completed column.
You probably don't want to store the number of days in the table (since his will change daily)-instead it calculate on the fly that you query the data (or if you have 11 g you could watch the virtual to make columns persistent calculation rather than the value in the table).
-
Number of days where the value >; a certain amount
Hello
I have a table named named MSR_3423:
I want to count the number of days where the VALID_VALUE is > to 0.001
I made this request, but it gives me that result a count of every time that this value has been found in a day:
select trunc(valid_date), count(*) from MSR_3423 where raw_value > 0.001 and VALID_DATE IS NOT NULL group by trunc(VALID_DATE) order by 1
It gives me this result:
But I want the number of days when this value has been reached. In this example, the result should be: 5 (for 5 days)
I think there must be a dower to do, but I'm not experienced enough to achieve this goal. Could you help her?
Thank you.
You almost have it. Just put another county around your account.
select count(*) from ( select trunc(valid_date), count(*) from MSR_3423 where raw_value > 0.001 and VALID_DATE IS NOT NULL group by trunc(VALID_DATE) );
or shorter but sometimes confusing
select count(count(*)) from MSR_3423 where raw_value > 0.001 and VALID_DATE IS NOT NULL group by trunc(VALID_DATE) ;
Logic of Alvertos did the same thing. He's just using SEPARATE instead of GROUP BY. But since I do not SEPARATE, I wanted to show a different way.
-
Get the number of days in a month based on the month and year of fields
I have a column in my form which lists the days in a month. I want to configure a hidden field that calculates the total number of days in a month, based on the month and year of the field inputs. The number of days will determine what appears on the column. For example, if I put 4 months, and 2016 in the field of the year, I get 30 in the hidden field. Thus, on the column 'Day', I'll have numbers 1-30. Or if I put 2 months and 2016 in the field of the year, I get the 29 in the hidden field. If the numbers 1-29 appears in the column 'day '.
Found this on some forum javascript code:
//Month is 1 based
function daysInMonth(month,year) {
return new Date(year, month, 0).getDate();
}
//July
daysInMonth(7,2009); //31
//February
daysInMonth(2,2009); //28
daysInMonth(2,2008); //29I do not know how to convert this code in JavaScript to adobe and don't really know how to use it. All I know how to do is to configure the field values for the field month and year as variables. I am a novice programmer and would appreciate it really all the help I can get. Thank you in advance!
The code seems to be JavaScript and runs as needed by using the JavaScript console.
I would like to consider making more general code, so if you have a date string that includes at least the month and year we could just call the function and get the number of days for that month.
The following script will calculate the number of days in a month, by using at least the month and year values can display the result on the JavaScript console and all of the value field for the field that has this code as the custom calculation Script.
function daysInMonth (oDate) {}
return new Date (oDate.getFullYear (), oDate.getMonth () + 1, 0) .getDate ();
}nMonth var = this.getField("Month").valueAsString; get the value of month;
nYear var = this.getField("Year").valueAsString; get the value of the year;Event.Value = "";
If (nMonth! = "" & nYear!) = "") {}
var MyDate = util.scand ("' / mm/yyyy ', nMonth +" / "+ nYear); convert to date object;
var nDaysInMonth = daysInMonth (MyDate); get the number of days;Console.Open (); Open the JavaScript console;
Console.clear(); clear the console;
Console.println ("Days in" + nMonth + ":" + nDaysInMonth); show days in month;
Event.Value = nDaysInMonth; Set the value of the field;
}
-
Is it possible to send a document through EchoSign, but not allow the recipient to sign in fact that a certain number of days later? I often send contracts which have a period of seven days - if the recipient is not allowed to sign until seven days have elapsed since the date I send the contract. I was wondering if there is a way to fight against this automatically or if I should tell them that they cannot sign up to a certain date and count on them to follow my instructions.
Hi Jamie,
From now on, once the document is sent to the signatories that they can esign it at any time and it is not possible to delay or set the least number of days before they can not esign.
Although EchoSign does not have this feature currently, but we can send your request to our team of developers to integrate the requested feature becomes available in the future.
You can also put your ideas on our page of ideas (http://ideas.echosign.com/forums/21617-echosign-general ) where your feature request will go directly to our development team.
Kind regards
-Usman
-
How to find the number of days between 2 date elements in the XSLT file
Hello
I need to calculate the number of days between 2 date elements (type xs: date). Can you please direct me as to how I can do the same thing.
I work in 11g and using XSLT 1.0. I tried several options but yet to get a solution for this. I think that this can be done also using XSLT 2.0, but who has not worked for me.
Can someone please help with this problem, thanks in advance!
Thank you
AnjuHello
Have you seen this message?
Re: Get the Date difference between 2 values of date in daysYou can do in the XSLT file since the dates are in ISO 8601 format.
http://www.w3.org/TR/NOTE-datetimeHere is a sample XSLT...
The XSLT above will result in * 4 * for the next entry...
2012-01-11T00:00:00.000-05:00 2012-01-15T00:00:00.000-05:00 You can test this example here...
http://xslttest.appspot.com/I hope this helps...
See you soon,.
VladIt is considered good etiquette to the answerers rewards with points (as "useful" - 5 pts - or 'correct' - 10pts)
https://forums.Oracle.com/forums/Ann.jspa?annID=893 -
++ Adding the number of days to an existing date
Hi team,
Try to add the number of days to an existing date.
Ex: If the date is May 28, 2012, I need to add 15 days. The deadline in the element should be June 12, 2012.
How to handle this in Application Express 4.1.0.00.32.
Would appreciate your answer by May 29, 2012.
Thank you in advance.
Kind regards
AnithaWhat is the date format in the date picker? Maybe give example date value
I guess it's something to your data format
Look at this example of work
http://Apex.Oracle.com/pls/Apex/f?p=46417:9
login: test/test
If your date format DD-MON-YYYY is then use this js code
//define the array of month names var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; var dateArray = $v('P2_WPTG_START_DATE').split("-"); for (var i = 0; i < monthNames.length; i++) { if (monthNames[i] == dateArray[1]) { var vmonth = i; dateArray[1] = vmonth; } } var d = new Date(dateArray[2], dateArray[1], dateArray[0]); //convert the string into date d.setDate(d.getDate() + 15); // add 15 days var newDate = (d.getDate()) + "-" + monthNames[d.getMonth()] + "-" + d.getFullYear(); $s('P2_PLANNED_RELEASE_DATE',newDate);
-
SQL query to get the number of days monthwise
Hello
I'm new to sql, can someone please tell me query to find the number of days between the two dates months wise.
say
FIRSTDATE last date
21/03/2011-25/06/2011
March April May June
9 22 23 18Hello
Welcome to the forum!
Here's one way:
WITH all_dates AS ( SELECT start_date + LEVEL - 1 AS a_date FROM ( SELECT TO_DATE ('21/03/2011', 'DD/MM/YYYY') AS start_date , TO_DATE ('25/06/2011', 'DD/MM/YYYY') AS end_date FROM dual ) CONNECT BY LEVEL <= end_date + 1 - start_date ) SELECT TO_CHAR ( TRUNC (a_date, 'MONTH') , 'fmMonth YYYY' ) AS month , COUNT (*) AS num_days FROM all_dates WHERE a_date - TRUNC (a_date, 'IW') < 5 GROUP BY TRUNC (a_date, 'MONTH') ORDER BY TRUNC (a_date, 'MONTH') ;
What is a 'working day '? I guess you mean every day except Saturday or Sunday, but the query aboveare sometimes figures less than you have asked:
MONTH NUM_DAYS --------------- ---------- March 2011 9 April 2011 21 May 2011 22 June 2011 18
Are a few days working on Saturday or Sunday? How do you get the 22 working days in April 2011 and 23 in may?
SQL is good at obtaining results with a variable number of rows, but you have to say exactly the desired number of columns when you write the query.
If you really need the output of the way you said, with any number of columns, then watch in swing or a grouping of the chain . See the FAQ forum
https://forums.Oracle.com/forums/Ann.jspa?annID=1535
"4. How can I convert rows to columns.
Maybe you are looking for
-
doubling of the photos when importing
-
Satellite M30 does not show the connection of the battery after 5 min of use
Hello My Satellite M30 recognize the battery when placed first in and for 5-10 minutes.After that the power meter shows I'm on sector without battery. Any advice? Anyone know if it is an issue that could be fixed with a new battery, or if it might ha
-
on the screen when it is plugged
Someone knows how to get the screen to continuously stay when its plugged into the only one?
-
load another photo library, can't see his albums
I just loaded another of my library of Photos. When I go to iTunes home sharing to specify what albums to share I do not see the library albums, I just loaded. How can I force iTunes what it is look at the library I just loaded?
-
I tried everything and the 1320c will not work on Windows 8.1. This infuriates me. I have to upgrade to WIN7, when I want to print in color. I installed it on my network. This kind of thing always happens when the BONE is altered. 8.1 WIN works