Round and Trunc with dates
Can i get the examples for Round and Trunc with dates?
Hi Rahul,
Check out this workout by Tom Kyte on TRUNC and ROUND -
http://www.oracle.com/technetwork/issue-archive/2012/12-sep/o52sql-1735910.html
Dont skip even a single line of it. Really useful.
My little workout :
Ranit>> select
2 round(123.444) r1,
3 round(123.999) r2,
4 trunc(123.444) t1,
5 trunc(123.999) t2
6 from
7 dual;
R1 R2 T1 T2
123 124 123 123
Ranit>> select
2 round(123.444,2) r1,
3 round(123.999,2) r2,
4 trunc(123.444,2) t1,
5 trunc(123.999,2) t2
6 from dual;
R1 R2 T1 T2
123.44 124 123.44 123.99
Ranit>> select
2 round(123.1234,2) r1, -- "Rounds upto 2 Decimal places"
3 round(123.1266,2) r2, -- "Rounds upto 2 Decimal places"
4 trunc(123.1234,2) t1, -- "Keeps only 2 decimal places and Truncates the rest"
5 trunc(123.1266,2) t2 -- "Keeps only 2 decimal places and Truncates the rest"
6 from
7 dual;
R1 R2 T1 T2
123.12 123.13 123.12 123.12
--"Note the difference in R2 andT2 values : In R2 there's a data round-off done but in T2 it is simple cut-off of extra decimal part"HTH
Edited by: ranit B on Jan 26, 2013 7:24 PM
Similar Messages
-
What is the difference between ROUND and TRUNC functions in SQL
The docs are your friends.
Round Number
Round Date
Trun Number
Trunc Date
Cheers
Sarma. -
FTPS settings Difference between control and control with data
Hi guys,
Just a very quick question please. When doing FTPS there are two options
1) control
2) control with data
Can anyone explain what's the difference between the two?
regardsHi,
FTPS (FTP Using SSL/TLS) for Control Connection
The FTP control connection is protected using TLS/SSL (Transport Layer Security/Secure Sockets Layer). File transfer is unencrypted.
FTPS (FTP Using SSL/TLS) for Control and Data Connection
All communication with the FTP server is encrypted and uses TLS/SSL.
Regards,
Raj -
Hi, all!
i have a question to get your help! now my oracle client running in SUN solaris communicate with oracle data server by OCI(oracle call interface). In future, my client system will port to embeded system that will use real time OS, such as PSOS, so i'm afraid that is OCI communicating with data server ok in PSOS environment??? Is there a special driver or OCI lib for PSOS?
thanks very much!!!
nullI have no idea which platforms the Oracle client has been ported to. If there exists an Oracle client for PSOS, then you should have no problem with OCI there. If there's no Oracle client for PSOS, then you won't be able to make OCI calls.
Regardless, this probably is a question better addressed to Oracle sales rather than to an ODBC forum.
Justin -
Guys,
About the query below, how is the output and how SQL treats that?
SELECT TRUNC(ROUND(156,00,-1),-1)
FROM DUAL
Thank you!Don't be afraid of breaking Oracle by actually trying things.
Break it into pieces and look at each piece one at a time.
Remove the TRUNC operation and see what you get. Do you understand why you get that result? If not, post it and we can help explain it.
But you need to make the effort yourself.
See the SQL Language doc. It has an example just like yours.
http://docs.oracle.com/cd/B28359_01/server.111/b28286/functions142.htm
>
ROUND returns n rounded to integer places to the right of the decimal point. If you omit integer, then n is rounded to zero places. If integer is negative, then n is rounded off to the left of the decimal point.
The following example rounds a number one digit to the left of the decimal point:
SELECT ROUND(15.193,-1) "Round" FROM DUAL; Round ---------- 20
>
Which means your number, 156,00, will get rounded one digit to the left of the decimal point. So 156 gets rounded to 160.00 since the '6' is equal to or larger than '5' it gets rounded up.
That leaves a result of 160.00. The TRUNC operation does something similar excepts instead of rounding one place left it truncates. But since one place left already has a '0' there is nothing for TRUNC to do so you still have 160.00 -
UI: Opening Sales Order screen and loading with data
Hi,
I'm currently using the SDK to develop a new screenin SBO. From my new screen I need to display the sales order screen with an order loaded into it.
I currently open the screen using the ActivateMenuItem methid, then use the sendKeys method to try and change to find mode, pass in the sales order number and press enter to start the search.
The code is this:
moSBOApp.ActivateMenuItem("2050");
moSBOApp.SendKeys("(^f)");
moSBOApp.SendKeys("123");
moSBOApp.SendKeys("{ENTER}");
But the form doesn't seem to change modes, it just stays in "Add" mode. Is there a better way of doing it?
I've also tried putting code in the FORM_LOAD event for the sales order screen and try and change mode then, but I just get an "Invalid Form Mode" error
Help!Ho Jon!
The following snippet works fine for PO searching by number and date:
SAPbouiCOM.Form frmPurchOrd = null;
int frmPOCount = 0;
SAPbouiCOM.EditText oOrdNum;
SAPbouiCOM.EditText oOrdDate;
SAPbouiCOM.Item oOrdOkButton;
SBOApp.ActivateMenuItem("2305");
// PO even opened
for (int k=0; k<SBOApp.Forms.Count; k++)
if (SBOApp.Forms.Item(k).Type == 142)
frmPOCount++;
frmPurchOrd = SBOApp.Forms.GetFormByTypeAndCount(142, frmPOCount++);
frmPurchOrd.Freeze(true);
frmPurchOrd.Mode = SAPbouiCOM.BoFormMode.fm_FIND_MODE;
oOrdNum = (SAPbouiCOM.EditText)frmPurchOrd.Items.Item("8").Specific;
oOrdNum.String = OrdNum;
oOrdDate = (SAPbouiCOM.EditText)frmPurchOrd.Items.Item("10").Specific;
oOrdDate.String = OrdDate.ToShortDateString();
oOrdOkButton = (SAPbouiCOM.Item)frmPurchOrd.Items.Item("1");
oOrdOkButton.Click(SAPbouiCOM.BoCellClickType.ct_Regular);
frmPurchOrd.Freeze(false);
it's too easy to implement it for Sales Order -
Hierarchical tree and interacting with data block
I have a hierarchical tree that is used to pick records that are shown in another data block. I have a list item in the data block that changes the arrangement of nodes in the hierarchy. My problem is that after the update, I select the node, but the wrong data shows up in the other data block (eg. node x is selected, x becomes a child of y, the data for y still appears in the data block even though node x is selected in the tree). There seems to be something wrong with my triggers, but I can't figure out what.
Here are the triggers that I am using.
In the tree block, tree item:
-WHEN-TREE-NODE-SELECTED
set_block_property(v_data_block, default_where, 'global_id = ' | | v_org);
go_block(v_data_block);
execute_query;
In the data block, list item
-WHEN-LIST-CHANGED:
-- find the tree node and select it
node := Ftree.Find_Tree_Node(...)
Ftree.set_tree_selection(v_tree,node,Ftree.SELECT_ON);
-- update the data block to show data from the selected node
set_block_property('GREENPAGES_DIR', default_where, 'global_id = ' | | :greenpages_dir.global_id);
go_block('GREENPAGES_DIR');
execute_query;
Thanks for your help.hi
i didn't try doing it.. i assume the the reasons can be:
1.check the value of the variable 'v_org' because 'w-t-n-s' trigger fires twice..
2. 'w-t-n-s' trigger is not firing eventhough u select it through ur code in the list item trigger.. if not firing, use execute_trigger('w-t-n-s') and remove the last set of code (update section) from the list item trigger..(assuming 'GREENPAGES_DIR' = v_data_block)
hope this helps u
ajith -
Subscribe event and processing with data
Hi.
We made a portal component with DynPageWithJSP model and this program subscribe event from other iview.
Other iview trigger event and store Data using data bag.
When event trggered my portal component, load data and I wan to process with this data in PAI routine.
So, Here is JSP file.
<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean id="SalesOrderBean" scope="application" class="com.sap.training.portal.SalesOrderBean" />
<script>
function eventFired () {
var Cust_No = EPCM.loadClientData('urn:com.sap.training.portal','Cust_No');
var Sales_Org = EPCM.loadClientData('urn:com.sap.training.portal','Sales_Org');
alert(Cust_No + " " + Sales_Org);
var funcName = htmlb_formid + "_getHtmlbElementId";
func = window[funcName];
var ipField1 = eval(func("Cust_No"));
ipField1.setValue(Cust_No);
var ipField2 = eval(func("Sales_Org"));
ipField2.setValue(Sales_Org);
var form = document.all(htmlb_formid);
form.submit();
EPCM.subscribeEvent('urn:com.sap.training.portal',
'SalesOrder',
eventFired);
</script>
<hbj:content id="myContext" >
<hbj:page title="PageTitle">
<hbj:form id="myFormId">
<hbj:inputField id="Cust_No" type="string" maxlength="20" value="" jsObjectNeeded="true" >
<% Cust_No.setVisible(false);%>
</hbj:inputField>
<hbj:inputField id="Sales_Org" type="string" maxlength="20" value="" jsObjectNeeded="true" >
<% Sales_Org.setVisible(false);%>
</hbj:inputField>
<hbj:textView id="welcome">
<% welcome.setText("Hello, " + SalesOrderBean.getCust_No() + " from " + SalesOrderBean.getSales_Org()); %>
</hbj:textView>
</hbj:form>
</hbj:page>
</hbj:content>
Above code, I checked portal compoent load data when event trigger. (in statement : alert(Cust_No + " " + Sales_Org);)
After then, I try to access that data using following code.
public void doProcessAfterInput() throws PageException {
InputField myInputField1 = (InputField) getComponentByName("Cust_No");
if (myInputField1 != null) {
this.Cust_No = myInputField1.getValueAsDataType().toString();
InputField myInputField2 = (InputField) getComponentByName("Sales_Org");
if (myInputField2 != null) {
this.Sales_Org = myInputField2.getValueAsDataType().toString();
IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
IPortalComponentContext myContext = request.getComponentContext();
SalesOrderBean myNameContainer = (SalesOrderBean) myContext.getValue("SalesOrderBean");
myNameContainer.setCust_No(Cust_No);
myNameContainer.setSales_Org(Sales_Org);
I can't acess it.
Is there any problem ?
Welcome to any comment.
Regards, Arnoldhi arnold
try placing submit button...and use onClientClick="eventFired" in jsp file...try this out...
hope it works fine...
regards,
purush -
[Solved] Still learning and stuck with 'date'
Hi there, I thought it was about time I learned the fine art of shell scripting, but as the title states, I'm stuck.
A file with some text, one of which is this:
Download time: September 8 12:17:37
This I need to grap and convert to a computer readable format, so that I may compare it with another.
This shouldn't be too hard:
cat ~/unitinfo.txt | grep 'Download time: ' | cut -c16- | xargs date +"%B %-d %T" -d
But, when I execute this above, I get the error:
date: extra operand '8'
I've tried various variations, but nothing seems to make a difference, all thought the format is a perfect match when I get 'date' to print it.
Please advice and best regards.
Last edited by zacariaz (2012-09-09 10:17:14)Just for the fun of it, if you care to comment on my progress so far:
unitinfo.txt:
Current Work Unit
Name: Gromacs
Tag: -
Download time: September 8 12:17:37
Due time: September 12 12:17:37
Progress: 25% [||________]
fah.sh:
#!/bin/bash
dueTime="$(date +%s -d "$(grep 'Due time: ' ~/unitinfo.txt | cut -c11-)")"
downloadTime="$(date +%s -d "$(grep 'Download time: ' ~/unitinfo.txt | cut -c16-)")"
currentTime="$(date +%s)"
progress="$(grep 'Progress: ' ~/unitinfo.txt | cut -c11-c12 | sed 's/ *$//')"
Now that I look at it again, am I correct that
sed 's/ *$//'
might as well be
sed 's/ $//'
In any case, there a long way to go.
Last edited by zacariaz (2012-09-09 22:20:45) -
Crontab, mkdir and mv with dates??
Message moved.
I have a crontab set up to move files every friday to a folder on admins desktop. That works just fine.
What I want to be able to do is add to the crontab to make a folder with the date and have the files transfer into that folder that was just created.
I have tried this command, but terminal just hangs..
mkdir /Volumes/.../Users/.../Desktop/5\ 2/`date '+%m-%d-%y'`; mv /Volumes/.../Users/.../Desktop/1.doc /Volumes/.../Users/.../Desktop/5\ 2/`date '+%m-%d-%y'
The mkdir works, but when i want to mv, terminal hangs.
Any ideas?Just to explain that, within any shell command you can embed another shell command within backticks. This has the similar effect to parentheses in mathematics - it runs that sub-command first and substitutes the output of that sub-command in the main command.
In the case of your mkdir command, the shell first runs the date '+%m-%d-%y' command since it's enclosed in backticks, then substitutes that in the mkdir command.
Without the trailing backtick the shell can't identify where the sub-command finishes, and therefore fails. -
Diff between Oracle 9i and 10g with date format MON in FRENCH language
Hi,
With a session in FRENCH language, when i do:
SQL> select to_char(sysdate,'dd-mon-yyyy') from dual;
The result in 10g is:
TO_CHAR(SYSDA
27-juil.-2005
The result in 9i is:
TO_CHAR(SYS
28-jul-2005
Where is the problem and how can i have the same result in 10g than in 9i ?
Thank you for your help.This behaviour is documented in the Oracle Database 10g Globalization Guide; it also includes the steps on how to revert back to the Oracle 9i locale definitions.
http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10749/applocaledata.htm#sthref1769
Please note that 10g is using the correct convention, the Oracle9i locale definition files will be desupported in a future release. -
I have real problems A with syncing and B with dates beeing displayed i Reminders.
the date for 15 october is reading 289/42/2012 which is the the number for the day and the week of the year!!
Hi,
Have you tried backing up you iPhone and copying over everything to iTunes etc.Apps,Videos...Then Restoring to factory setting?
If that doesn't work try Manually Managing you Music and Videos. -
Call program and return with data
Hi, Experts,
I have called a program from my main program using SUBMIT
and return.
I need to get data back from called program in table format.
Is there any way to fullfill such requirement.
Regards
Rajiv singh.if the program is custom , then you can use import and export option. you can export the data to memory in the submit program, and import from memory after submit call.
if it Standard program , in some standard programs also will export data to memory , so check in inside the program. -
Record count is different for Full load and Init with data transfer
Hi all,
We have a data source for which delta is enabled on Calendar Day.
If I run the full load record count is 2670.But If I run the delta record count is 2665.5 records are missing.
Would you please help on this.Why those records are missing.Hi,
Actually for Full Load say you have 50 records. When you run it will upload 50 records.
Now if you run delta if there is no records changes it wouldnt update because there is no update in the existing records.
only delta is done when there is changes in the records. -
Cube loaded with data, but unavailable in the query
Hello everyone,
Someone can help me?
I created a new Cube CO-PA for the year 2010, and loaded with data this year. To make sure that the data were correct did a ListCube, with all the filter equal to the query, and indeed the data is loaded properly for this year. And when i run the query with data from the years 2008 and 2009 show me data in my report, but when I run the query for 2010, the query displays an error message saying that "no data".
How is it possible to have the correct data in the Cube, and i can not view the data in the query?
Note: The request in the cube is available to report
Thank you all,
Greetings,
Maria João
30-Março 2010Hello,
I was in trouble because I had not selected the key figures in the multicube : S
After selecting the key figures, I ran the query and it had data.
Thank you for your help.
Sincerely,
Maria Joã
Maybe you are looking for
-
An error occured while retrieving policy for this computer 0x80092004
Good morning! I have recently been having some issues getting my OSD working correctly. It all started after the server which houses DPM and SCCM was refusing to start the SQL service because of an invalid certificate that was missing the private key
-
Hi all, I want to block a material for procurement. I set Plant-sp.matl st indicator to "01" in purchasing view in material master. Now the issue is that system stops to create reservation for existing stock for that material. What changes i have to
-
ActiveX RDP Fullscreen Resolution
This is not a question, but a very simple solution to a problem that had us scratching our heads for quite a while. Hopefully this will save someone else some time figuring it out. We use the Clientless SSL VPN with a terminal server for our general
-
I ran into a problem with web gallery creation. The problem is that LR uses the image file name, without the extension, to create the small images and the html documents. No image renaming is done. Now I am trying to create a website, and conflicts
-
Upgrade to iphoto 9.4.2 crashes on startup
bought a new imac and downloaded latest iphoto. When I import the last (260Gb) database it goes through an 11 step conversion, than hangs indefiinitely while updating thumb images.