Date Substract Format
I'm trying to format following query.
SELECT TO_CHAR(START_DATE, 'HH:MM:SS'), TO_CHAR(END_DATE, 'HH:MM:SS'),
TO_CHAR(END_DATE - START_DATE, 'HH:MM:SS')
FROM TIMES
Oracle returns following message:
ORA-01481: invalid number format model
Somebody knows how to convert from number to date values?
I appreciate some help
Best regards
The problem is that when you subtract two dates, Oracle returns a number -- which is the 'portion of the day' -- you can take the result and multiply it by 86400 to get the number of seconds in a day and then convert that back to a date... Once this is converted back to a date - you can then convert it to a character - with your date format... Sounds kind of sloppy - and it is, but it works..
here's the example i used (which is REALLY SLOPPY)
SELECT TO_CHAR(TO_DATE(((SYSDATE - TO_DATE('28-JUN-2002 08:00','DD-MON-YY HH24:MI')) * 86400), 'SSSSS'), 'HH:MI:SS') FROM DUAL
Now, I'll attempt yours without testing..
SELECT TO_CHAR(START_DATE, 'HH:MM:SS'), TO_CHAR(END_DATE, 'HH:MM:SS'),
TO_CHAR(TO_DATE(((END_DATE - START_DATE, 'HH:MM:SS') * 86400), 'SSSSS'), 'HH:MI:SS')
FROM TIMES
Hope this helps!
Michelle
I'm trying to format following query.
SELECT TO_CHAR(START_DATE, 'HH:MM:SS'), TO_CHAR(END_DATE, 'HH:MM:SS'),
TO_CHAR(END_DATE - START_DATE, 'HH:MM:SS')
FROM TIMES
Oracle returns following message:
ORA-01481: invalid number format model
Somebody knows how to convert from number to date values?
I appreciate some help
Best regards
Similar Messages
-
Hi all,
I have a question regarding Date substraction. I've read somewhere that the standard unit of Date Substraction of Oracle is days. However my requirements is to have result format in hours. Example:
Date1: 1/21/2010 08:00:00 AM
Date2: 1/22/2010 10:00:00 AM
Date2 - Date1 = 1 (day). If I need to convert to hours, I can achieve by multiply it by 24. But in fact the result for this should be 26 hours.
1 more example for this:
Date1: 1/21/2010 08:00:00 AM
Date2: 1/21/2010 10:00:00 AM
Date2 - Date1 - 0 (day). While in fact it should be 2 hours.
In short, I want Date substraction to give me result in hours rather than days. Is there anyway to achieve this objective using pure SQL in Oracle? or do I have to manipulate using some kind of programming language?
I've received a reply from the other thread saying that I could get the number of hours by mulitply the number of days by 24. This is true only if Oracle stores data in format like: 1.2 days after substraction. Is this the case with Oracle?
Thank you very much.
Thanh.babaravi wrote:
use extract function. you can achieve it.
1 SELECT EXTRACT(HOUR FROM
2 (SYSTIMESTAMP - TO_TIMESTAMP('30.07.2009 10:00:00', 'DD.MM.YYYY HH24:MI:SS'))) AS hour
3* FROM dual
SQL> /
HOUR
23
SQL>
?:|
The OP asked for Date substraction, not timestamps. Also, your solution doesn't give the total number of hours between the date/times...
SQL> ed
Wrote file afiedt.buf
1 SELECT EXTRACT(HOUR FROM
2 (SYSTIMESTAMP - TO_TIMESTAMP('30.07.2009 10:00:00', 'DD.MM.YYYY HH24:MI:SS'))) AS hour
3* FROM dual
SQL> /
HOUR
22
SQL> ed
Wrote file afiedt.buf
1 SELECT (SYSDATE - TO_DATE('30.07.2009 10:00:00', 'DD.MM.YYYY HH24:MI:SS'))*24 AS hour
2* FROM dual
SQL> /
HOUR
6982.25944
SQL>Just a slight difference. ;) -
Specifying date time format in Finder
How can I specify the date-time format in Finder for the "date-modified" and "date-created" columns in list view?
About three years ago, I got a command line instruction to set these formats and I kept it at mm/dd/yy
Then a couple days ago, I changed the date format in iStat menus and the date-time formats started acting weird. I want the dates to be like "07/08/05" (mm/dd/yy) and then the formats started changing to "November 07, 2008" (month/dd/yyyy). This change seemed to take effect any time I open the view options for a folder. Now I discovered that the date format change depending on the column width according to the format specified in system preferences, international, formats.
Narrow column, short date format; a little wider to long format, with ellipses if the column is not wide enough; then full format.
Does anyone know the command line to set the format to keep it to the one I want?this doesn't seem to be it. however I now like the way Finder does display dates -- format gets more compact as the width of the column decreases; although there still is some excess space left on the left -- perhaps for AM & PM which I don't use; I use a 24 hour time format instead.
Happy New Year -
Trasnform current date to format MM/dd/yyyy HH:mm:ss AM/PM
Hi All,
How do I transform current date to format MM/dd/yyyy HH:mm:ss AM/PM?
I am able to get the format MM/dd/yyyy HH:mm:ss by using the standard date function. How do I get AM or PM to end of MM/dd/yyyy HH:mm:ss??
Thanx
NavinHi Navin,
How AM/PM is added? In the sample values given its in 24 hrs notation. Are u sure you want to add AM/PM to this notation? or U want to change this 24 hrs notation into 12 hrs and add AM/PM?
For converting into 12 hrs and appending AM/PM you can use this code:
input a:
int hr = Integer.parseInt(a.substring(11,13));
String appendVal = "AM";
if(hr > 12){
hr = hr - 12;
appendVal = "PM";
} else if(hr == 12){
appendVal = "PM";
} else if(hr == 00){
hr = hr + 12;
Sting finalVal = a.substring(0,11) + String.ValueOf(hr) + a.substring(13,a.length()) + appendVal;
return finalVal;
Regards,
P.Venkat
Message was edited by:
Venkataramanan -
Hi All,
I'm back already! Learning Flash is beginning to get to me
again so I returned for yet more help!
I've written the following AS code to get tomorrow's date . .
// Calculates today's date and tomorrow's date
var dToday:Date = new Date();
dToday.getDate()
trace("today: " + dToday) //today's date
myD = dToday.getDate() + 100; // plus one day
var dTomorrow:Date = new Date();
dTomorrow.setDate(myD)
trace("new: " + dTomorrow) //tomorrow's date
var strDate:String = new String();
var strDate = String(dTomorrow);
trace("String: " + strDate);
The strDate string returns the following value . . . "Tue Jul
11 16:19:57 GMT+0100 2006".
That is all well and good but I want to convert it into the
following format for comparison with another field . . .
"200607111619" which is basically the same value in the following
format . . . "yyyymmddhhmm".
Does the only way of doing this involve using parsing logic
to break down the original string and then reconstruct it in the
required format using variables from the broken down original
string?
I have tried looking at the Date Field object notes in my
book but it does not give me anything as regards this programming
requirement. The only thing I can find that might suit this purpose
is string parsing logic. Am I right or is there an easier way to
set a date field format?
Any help would as always be much appreciated!
Thanks,
Kevin.I'm working on an application which requires a valid Voucher
Number to proceed. The Voucher number is based on a combination of
'date/time/no of items' (e.g. 20060711095802 which is today at
09:58 (on a 24 hr clock) for 2 (02) items).
As this date this date/time Voucher Number logic is
essentially sequential, in that each subsequent Voucher Number will
be greater than the last good known Voucher Number entered into the
application (which is already stored in a variable field for
comparison). But it must also be less than tomorrow's date, for
which the Voucher Number would always be tomorrow's date (e.g.
20060712 at 00:00 hrs for 00 items, thus giving 20060712000000).
This is the value that I'm trying to ascertain from the date field
logic.
It would thus be really handy for comparison if I could just
format tomorrow's date and time in the format yyyymmddhhmm and just
add '00' to the end of the string.
I don't like the idea of using the milliseconds value as it
will be necessary then to convert the Voucher Number entered to a
date field for comparison. -
How do you add a format to the "Date Picker Format Mask" available formats?
Hi,
When I select the Date Picker Format Mask or "Number / Date Format" they doen't have YYYYMMDD or others that may be desired...
How do you add a format to the available formats?
Thank you, BillBill - From the popup help text:
If you need to create a Date Picker item, but the format you need does not appear in the Display As list, select Date Picker (use application format mask). When an application uses this type of date picker, the Application Express engine derives the date format from an item named PICK_DATE_FORMAT_MASK. You can populate this item in two ways:
- By defining an application substitution string named PICK_DATE_FORMAT_MASK
- By creating an application-level item named PICK_DATE_FORMAT_MASK
See the doc for more details.
Scott -
Convert Epoch Date Time to Date Time format
I am trying to convert Epoch Date time in GMT to Human Readable Date time format in UTC. I used the one below but it returns just the date in GMT but how can get datetime in UTC ?
select To_Char( To_Date( '01.01.1970 06:00:00','DD.MM.YYYY HH24:Mi:Ss') + STARTIME / 86400,'DD.MM.YYYY HH24:Mi:ss') FROM HQ_AVAIL_DATA_RLE;
I refered a couple of forums and applied everything, but still I wouldn't get the timestamp.
Please note that i'm looking for datetime stamp, not just the date.
Thanks in advance!
Edited by: 830754 on Jan 27, 2011 11:18 AM
Edited by: 830754 on Jan 27, 2011 11:19 AMWorks for me. I see date and time (submitted 1000 for STARTTIME):
select To_Char( To_Date( '01.01.1970 06:00:00','DD.MM.YYYY HH24:Mi:Ss') + 1000 / 86400,'DD.MM.YYYY HH24:Mi:ss')
from dual
TO_CHAR(TO_DATE('01
01.01.1970 06:16:40Or do you mean something else? -
Date/Time Format Stored Procedure Calls in ADVANCE MODE in JDBC ADAPTER
Hi Experts,
What is significance of Date/Time Format Stored Procedure Calls in ADVANCE MODE in JDBC ADAPTER.
Thanks,
ABDURI guess this would be applicable for the folowing formats - DATE, TIME, TIMESTAMP.
This is the correct link
http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/content.htm
Regards,
Prateek -
The file should be in XML-DATA-TEMPLATE format
Hi,
When I am trying to upload the Data Definition file in XML publisher with EBS 11.5.10.2, I got "The uploaded file GLPAYBDXDO.xml is invalid. The file should be in XML-DATA-TEMPLATE format". I have tried changing the file name to different names including XML-DATA-TEMPLATE but I could not succeed. I appreciate for any help.
Thanks,
Ram.What is the content of your xml file. Is this sample xml file or Data Template.
-
Browser date field format in header
I am using Browser 2.0 for some ad hoc queries on an Oracle
7.2.3 database.
My client is running Windows NT 4.0 with Service Pack 4.
Regional settings are set to English (Australia).
The page setup in Browser allows you in the header or footer to
insert the a date field via "&d". Documentation states this is
system generated.
However, in the print preview and print out the date is
formatted as MM/DD/YY. I need to have it formatted as DD-MON-
YYYY.
Can anyone suggest to me from which system the format is being
generated or any
suggestions on how to change it in.
Thanks
nullcan you paste the timestamp being displayed?
You can use, format-date function or other, but its all based on the data you have for DATE. -
Default date should be displayed in Locale's date short format in Prompt
Dear BI Gurus,
I would like to take your attention to resolve one of date format issue which we are currently facing.
We want to display Current_Date in locale's date short format ( For US: MM/DD/YYYY and for UK: DD/MM/YYYY) in a dashboard prompt. Also we need to pass the the prompt value to the report filter through presentation variable.
For this we used logical sql to get the default value as select Times.time_id from sh when times.time_id= Current_Date. Once I click on the preview button it was showing in locale's date short format. But when we place the prmpt in dashboard, the default date was coming up in 'YYYY-MM-DD' format. But since calendar picker is giving value in locale's date short format (For US: MM/DD/YYYY and for UK: DD/MM/YYYY), there is an inconsistency in the display format. So could you please provide any workaround to make them consistent.
Thnaks,
Siva Naga Hari.
Edited by: user6371352 on 27-Mar-2010 13:50Hi Vinay,
Thanks for reply.
We are looking for default date display format in dashboard prompt. i.e For US locale, default date and calendar picker should be displayed in MM/DD/YYYY and for UK locale, default and Calendar picker should be displayed in DD/MM/YYYY.
We don't have any problem in report output for different locales. Also we don't need to create 2 seperate reports for different locales. If we set the data format to [FMT:dateShort], it will display as per the locale's date short format. Please provide workaround to display in dashboard prompt.
Thanks,
Siva Naga Hari. -
How to get date in format(1st jan 2006 ).
can we get get the date in the 1st jan 2006 format .
we can get the date in format 1 jan 2006 by using (d MMM yyyy) but i am not able to get st, nd, or rd after the day in(d mmm yyyy)format like 1st 2nd 3rd 4thSearch and thou shall find. I read a similar thread just yesterday, school task?
you can say that you have a String postfix, which is set like this:
String postfix = "";
switch(dayOfMonth) {
case 1:case 21:case31: postfix = "st"; break;
case 2:case 22: postfix = "nd"; break;
case 3:case 23: postfix = "rd"; break;
default: postfix = "th";
} -
GregorianCalendar datetime format convert to sql server date time format
please help me
my GregorianCalendar date time format is like this. *08/01/29 02:25:59* . I try to insert my database(sql server 2000 )
data type is datetime ,in my database table display like this *2029-08-01 02:25:59.000* .can you help me to insert correct date in my database table like ( . *08/01/29 02:25:59*)use [PreparedStatement |http://java.sun.com/javase/6/docs/api/java/sql/PreparedStatement.html] and setTimestamp:
[http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html] -
Data template is invalid. Should be in XML-DATA-TEMPLATE format.
Hi,
I am trying to create & upload a Data Template for a Data Definition in XML Publisher. When I try to upload my data template, it shows me the error :-
" The uploaded file PAFPURUP_TEMPLATE.xml is invalid. The file should be in XML-DATA-TEMPLATE format. "
Can any please suggest me a possible resolution to this error? Below is my data template content :-
<?xml version="1.0" encoding="WINDOWS-1252" ?>
<dataTemplate name="PAFPURUP_TEMPLATE" description="Data template for PAFPURUP" defaultPackage="PA_PAFPURUP_PKG" version="1.0">
<parameters>
<parameter name ="count" dataType="character" defaultValue="10"/>
</parameters>
<dataQuery>
<sqlStatement name="Q1">
<![CDATA[SELECT BUDGET_VERSION_ID, VERSION_NAME FROM PA_BUDGET_VERSIONS WHERE ROWNUM <= :count]]>
</sqlStatement>
</dataQuery>
<dataTrigger name="beforeReport" source="PA_PAFPURUP_PKG.beforeReportTrigger"/>
<dataStructure>
<group name ="G_BUDGET_VERSIONS" source="Q1">
<element name="Budget_Version_Id" value="budget_version_id"/>
<element name="Version_Name" value="version_name"/>
</group>
</dataStructure>
</dataTemplate>
Many Thanks,
NiranjanHi Fred,
Thanks for your response. The issue was actually with the xml format. I had missed '?' at the end of 1st line of the xml.
Regards,
Niranjan -
Custom date validation format for dff field
requirement -
dff has a specific date time format different from the standard valuesets for date-time stamp available in apps. So if the user enters the incorrect format, it should do the validation.
Format needed for dff is : 2012-04-30 15:46:35
I tried a couple of thigs but dint fork . How do I do it.
any suggestions ?
ThnksThis topic was discussed many times in the forum before, please see old threads for details.
https://forums.oracle.com/forums/search.jspa?threadID=&q=dff+AND+Validation&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
https://forums.oracle.com/forums/search.jspa?threadID=&q=dff+AND+Validate&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
https://forums.oracle.com/forums/search.jspa?threadID=&q=dff+AND+Validation+AND+Personalization&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
Thanks,
Hussein
Maybe you are looking for
-
iTunes will not update. I get an error message saying that it cannot verify signature and it will be unable to install.
-
T430 Multiple Monitor question
Real simple question. Will a T430 with the Intel HD Graphics card support both a monitor connected to the VGA port AND a monitor connected to the Mini DisplayPort simultaneously? My User will have a desktop monitor and a wall mounted large screen dis
-
Family guy season 6 completely destroyed itunes
I purchased family guy season 6 at 11/24/2007 and was not able to play any of the episodes, for 2 of the episodes, amount of time for the episode did not display and whenever I tried to play them itunes would stop working immediately, and the compute
-
Problem when adding new registration in SQL Server2000
I couldn't add new registration in SQL Server2000 using SQL Server Authentication mode even I've already entered correct server name, username sa and correct password. I've tried to ping this server from command line and it's ok. But if I run Windows
-
Separating a phone from an existing account
Please help me to determine the cost of separating my existing Verizon Wireless account and create my owe account profile for billing.