How to subtract time from dateTime in xquery?

How to subtract time from dateTime in xquery??
In ALDSP i tried to use the function xf:add-days but it is showing an error saying invalid function name. I think this namespace is not valid for ALDSP. Is there is any way to add this function in ALDSP???

xquery functions and operators documentation is here :
http://www.w3.org/TR/xpath-functions/
It sounds like you want to ..
op:subtract-dayTimeDuration-from-dateTime
this is not an xquery function that you can call, it is an xquery operation defined by the specification
I believe you can simply use the '-' operator to use that operation.
<newDateTime>
{ $myDateTime - $myTime }
</newDateTime>

Similar Messages

  • How to subtract Time from Sysdate

    Hello,
    I want to subtract time from sysdate and get the sysdate with time.
    Example : = (Sysdate with time)03-mar-2002 16:40:55 - 8 (hours). The result should be like :03-mar-2002 08:40:55
    How to write a query for this?.
    Please let me know as soon as possible.
    Thanks,
    Ravi.

    Hi Ravi...
    SYSDATE includes time, TRUNC(SYSDATE) does not include time.
    If you subtract these two, you'll get a positive number of 1.00 or less which is the fraction of a day. For instance high noon would have a fraction of 0.50000. 12:01 p.m. would be 0.50000 + (1/(24*60)), or 0.50069444....
    If you want to set the clock back, by calculating a "date" that is 8 hours less than the SYSDATE, then SYSDATE - (8/24) will do that. This will work even if SYSDATE was something like 2 a.m., because it will then set it to 6 p.m. of the day before the day in SYSDATE.
    If you want to set a "date" to a specific time on the day of SYSDATE, then calculate the fraction for that time and add it to the TRUNC(SYSDATE). High noon would be TRUNC(SYSDATE) + 0.5.
    SELECT TO_CHAR(TRUNC(SYSDATE)+0.5,'DD-MON-YY HH:MI:SS am') AS NOON FROM DUAL;Hope this helps...
    Larry Johnson

  • Subtract Time  from Time

    Dear Sir,
    I want to subtract Time from time, Please help me
    SELECT A.EMP_CODE,
    TO_DATE(A.INTIME,'DD/MM/RR')IN_DATE
    ,MIN(TO_CHAR(A.INTIME,'HH24:MI')) IN_TIME
    ,MAX(TO_CHAR(A.OUTTIME,'HH24:MI')) OUT_TIME
    ,TRUNC(SUM(A.TDAYS)*24)||':'||TRUNC((SUM(A.TDAYS)*24-TRUNC(SUM(A.TDAYS)*24))*60) TOTAL_TIME
    FROM HCM.EINOUT A, HCM.PERSONNEL B
         WHERE A.EMP_CODE = B.EMP_CODE AND
         TO_DATE(A.INTIME,'DD/MM/RR')BETWEEN
         TO_DATE('01/08/12','DD/MM/RR') AND TO_DATE('15/08/12','DD/MM/RR')
         AND B.DEPT_CODE = 16 and a.emp_Code = '09833'
         GROUP BY A.EMP_CODE, TO_DATE(A.INTIME,'DD/MM/RR')--, a.tdays
         ORDER BY 1, 2 ASC;
    I want to subtract 20:00 from (out_time) column from every record
    If I subtract it from first record then result in over_time column will be 2:46
    (out_time - 20:00)
    --------------Out put........................
    code date in_time out_time total_time over_time
    09833     02-AUG-12     09:18     22:46     13:28
    09833     03-AUG-12     09:16     21:50     12:34
    09833     04-AUG-12     09:28     21:41     12:13
    thanks

    this will help
    --And if difference can be > 24 hours:
    WITH t AS
         (SELECT TO_DATE ('26-aug-2011 10:10:10',
                          'dd-mon-yyyy hh24:mi:ss'
                         ) start_date_time,
                 TO_DATE ('26-aug-2011 10:12:10',
                          'dd-mon-yyyy hh24:mi:ss'
                         ) end_date_time
            FROM DUAL)
    SELECT    TRUNC (end_date_time - start_date_time)
           || ' days '
           || TO_CHAR (TRUNC (SYSDATE) + (end_date_time - start_date_time),
                       'hh24:mi:ss'
                      ) time_diff
      FROM t
    --Or interval based solution for < 24 hour diff:
    WITH t AS
         (SELECT TO_DATE ('26-aug-2011 10:10:10',
                          'dd-mon-yyyy hh24:mi:ss'
                         ) start_date_time,
                 TO_DATE ('26-aug-2011 10:12:10',
                          'dd-mon-yyyy hh24:mi:ss'
                         ) end_date_time
            FROM DUAL)
    SELECT REGEXP_SUBSTR (NUMTODSINTERVAL (end_date_time - start_date_time, 'day'),
                          '\d\d:\d\d:\d\d'
                         ) time_diff
      FROM t
    --interval based solution for >= 24 hour diff:
    WITH t AS
         (SELECT TO_DATE ('26-aug-2011 10:10:10',
                          'dd-mon-yyyy hh24:mi:ss'
                         ) start_date_time,
                 TO_DATE ('26-aug-2011 10:12:10',
                          'dd-mon-yyyy hh24:mi:ss'
                         ) end_date_time
            FROM DUAL)
    SELECT REGEXP_REPLACE (NUMTODSINTERVAL (end_date_time - start_date_time,
                                            'day'),
                           '^.0*(\d+) (.{8}).+$',
                           '\1 days \2'
                          ) time_diff
      FROM t
    --another method
    SELECT    TO_CHAR (TRUNC (nb_sec / 3600), '00')
           || ':'
           || TO_CHAR (nb_min - TRUNC (nb_sec / 3600) * 60, '00')
           || ':'
           || TO_CHAR (MOD (nb_sec, 60), '00')
      FROM (SELECT (end_date_time - start_date_time) * 24 * 3600 nb_sec,
                   (end_date_time - start_date_time) * 24 * 60 nb_min
              FROM ps_tb_ln_pdc_status_log)
    --another method
    SELECT SYSDATE + 3.45 / 24 AS "End Date", SYSDATE AS "Start Date",
           CAST (SYSDATE + 3.45 / 24 AS TIMESTAMP) - SYSDATE AS "Duration"
      FROM DUAL;Regards,
    friend.

  • SUBTRACT TIME FROM DATE & TIME

    Hi.
    I need FM which will SUBTRACT TIME from DATE & TIME.
    Example:
    Date = 05.05.2007
    Time = 05:00:00
    Time_subtract = 48:00:00
    Return of FM:
    Date = 03.05.2007
    Time = 05:00:00
    Do you know any FM?
    Thanks!

    Hi, Check these function mod's
    SD_DATETIME_DIFFERENCE
    HRCM_TIME_PERIOD_CALCULATE
    HR_ECM_GET_PERIOD_BETW_DATES
    After you execute them in SE37 give the required input and you will get a correct output.
    <b>REWARD IF USEFUL</b>
    thanks n regards
    Dinesh

  • Formula for subtracting time from a datetime field

    I have a field that is formatted as a datetime field. I just need to know how to subtract 3.5 hours from this time. How do I write a formula in crystal reports kindly help me.
    Thanks in advance
    Ramakrishna Reddy

    This should do the trick...
    DateAdd("n", -210, {TableName.DateField})
    HTH,
    Jason

  • How to get Time from Different Work Station on the Network

    Hi,
    How do I get time from different work station on the network using its ip:port etc.
    Lets say, my main server-side Java application is running on a work station 123.12.123.1:1527,
    the client-side applications are accessing it using above IP.
    what I wanna do is, use the time of 123.12.123.1 machine throughout the application, not client local time.
    Appreciated..

    Ok, this network service on IP:Port is working for me, I hope this is the best way of doing it.
    In server application, I have this
    package RenameItToYourOwnPackage;
    import java.io.IOException;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    import java.net.ServerSocket;
    import java.net.Socket;
    import java.text.SimpleDateFormat;
    public class ServerSocketExample implements Runnable {
        private ServerSocket server;
        private int port = 7777;
        Socket socket;
        public void run() {
            try {
                System.out.println("Waiting for client message");
                server = new ServerSocket(port);
                while (true) {
                    socket = server.accept();
                    // Read a message sent by client application
                    ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
                    String clientMessage = (String) ois.readObject();
                    System.out.println("Message sent by client: " + clientMessage);
                    // send current datetime to client
                    ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
                    oos.writeObject(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new java.util.Date()));
                    ois.close();
                    oos.close();
                    socket.close();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
    }In the client application I have
    package RenameItToYourOwnPackage;
    import java.io.IOException;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    import java.net.InetAddress;
    import java.net.Socket;
    import java.net.UnknownHostException;
    public class ClientSocketExample {
        static String dateTimeString;
        public ClientSocketExample() {
        public static String getServerDateString() {
            try {
                // Create a connection to the server socket on the server application
                InetAddress host = InetAddress.getByName("127.0.0.1");
                Socket socket = new Socket(host.getHostName(), 7777);
                // Send a message to the server application
                 ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
                 oos.writeObject("Send me today's timestamp as string");
                // Read the response by server application
                ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
                dateTimeString = (String) ois.readObject();
                //System.out.println("Message sent by server: " + message);
                ois.close();
                oos.close();
            } catch (UnknownHostException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            return dateTimeString;
    }And I run the service on the server-side with
            new Thread(new ServerSocketExample()).start();On the client-side I receive the date with
            System.out.println("DateTime on Server : " + ClientSocketExample.getServerDateString());Edited by: nkamir on Sep 13, 2010 2:53 PM

  • How to get time from Date

    I have a Column that is defined as "DATE".it also Contains Time.........
    I want to Get the Time only....so when i am using this
    to_date(var_date,'hh12:mi:ss PM'),it is giving me date also and when i am using this
    to_char(var_date,'hh12:mi:ss PM') then it is giving me all values similar to one of the top values in Column....
    Then i Used EXTRACT function as
    Select EXTRACT(HOUR FROM VAR_DATE).......
    THEN IT THRWOING ERROR.......INVALID EXTRACT FIELD FOR EXTRACT SOURCE........
    pLZ HELP HOW TO GET TIME...................................ONLY WITH AM AND PM......
    Thanks in Advance

    Hi,
    to_char function should give the result as expected.
    SQL> select to_char(sysdate, 'hh12:mi:ss PM') from dual ;
    TO_CHAR(SYS
    11:39:16 AM
    SQL> select to_char(sysdate, 'hh12:mi:ss AM') from dual ;
    TO_CHAR(SYS
    11:39:32 AM
    SQL> select to_char(sysdate,'hh:mi:ss') from dual ;
    TO_CHAR(
    11:40:04
    SQL> select to_char(sysdate,'hh:mi:ss am') from dual ;
    TO_CHAR(SYS
    11:40:18 am
    SQL> select to_char(sysdate,'hh:mi:ss pm') from dual ;
    TO_CHAR(SYS
    11:40:31 am
    Thanks,
    Siva

  • How to subtract days from day

    Hi,
    how to subtract 18 days from day : 04-10-2004
    rgds,
    Karna

    SQL> select to_date('04-10-2004','dd-mm-yyyy')-18 from dual
    SQL> /
    TO_DATE('0
    16/09/2004
    SQL>

  • How 2 prevent time from changing on leopard and vista?

    if i maintain successive boots into the same OS on my macbook, the time is shown correctly, whereas on booting into another OS changes the time. how to prevent this from happening?
    Neerav

    From what my brother says says about his set-up (he boots into 64 bit Vista periodically), apparently you can't. My understanding is that the two systems do a different version of time at boot, Vista uses a GMT setting in bios, and I think Mac use a local time in EFI. Anyway, the result is several hours difference between the two. I don't use Boot Camp, but I would think if you are on a network with Internet access, you should be able to have the clock reset automatically using System Prefs->Date and Time, and check the box at the top to automatically set the time from the Apple time server.
    Francine
    Francine
    Schwieder

  • How to use time from external source as signature time?

    Hi,
    I have a PubSec based acrobat X plugin for signature creation and verification. So far i knew that acrobat was using my local system time to get signing time and saved that time in the signature dictionary. Now i have to get the signing time from an NTP server, which is different from my local system time, and I want to put this time in the signingTime (M) of the Signature dictioniary. But so far i am unable to modify the (M) dictionary value.
    Can you please guide me to achieve this goal?
    thanks

    thanks for your prompt reply.
    actually, using timestamps is not an option. Machine time can be changed and my requirement is to use NTP time during signing and set this time as signing time in the signature dictionary. I have tried adding the time in M dictionary in SigGetSigProperties() and SigGetSigValue() callbacks, but it has no effect.
    My question is, is it possible to use time other, than machine time, as signing time in a signature (in signature dictionary) ?
    If yes, then can i achieve this, a hint or a point in the right direction can suffice.
    if no, then is this limitation part of the new plugin framework? because as far as i remember, it was allowed in digsig plugins.
    Finally, can i achieve my goal in an unorthodox way?
    thanks

  • How to prevent timer from repeats

    hello there i've made a countdown timer
    and i want it when it finishes counting till 0 not repeating from the beginning but do some action
    i uesd the method
    timer.setRepeats(false);but it stops the timer from counting
    i'm using javax.swing.timer;
    and here is the code:
    import java.math.*;
    import java.util.*;
    import java.text.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class Timer1 extends JFrame {
       JComboBox combo = new JComboBox();
       JButton start = new JButton("Start");
       JButton stop = new JButton("Stop");
       JButton clear = new JButton("Clear");
       JTextField time = new JTextField("");
       javax.swing.Timer timer;
       SimpleDateFormat timef = new SimpleDateFormat("HH:mm:ss",Locale.getDefault());
       long startT,stopT;
       Date date=new Date();
       public Timer1() {
          super("Timer");
          timef.setTimeZone(TimeZone.getTimeZone("GMT"));
          addWindowListener(new WindowAdapter() {
             public void windowClosing(WindowEvent ev) {
                dispose();
                System.exit(0);
          setBounds(10,10,400,200);
          getContentPane().setLayout(null);
          start.setBounds(10,30,100,24);
          start.setBackground(Color.green);
          stop.setBounds(10,60,100,24);
          stop.setBackground(Color.red);
          combo.setBounds(10,90,100,25);
          combo.setBackground(Color.blue);
          clear.setBounds(150,60,100,24);
          clear.setBackground(Color.green);
          combo.addItem("1 Hour");
          combo.addItem("2 Hours");
          combo.addItem("3 Hours ");
          combo.addItem("4 Hours");
          combo.addItem("5 Hours");
          combo.addItem("6 Hours");
           combo.addItem("7 Hours");
          combo.setSelectedIndex(0);
          start.addActionListener(new ActionListener() {
             public void actionPerformed( ActionEvent e ) {
                try {
                     startT=(combo.getSelectedIndex()+1)*60*60*1000;  // change if combo box values changed
                catch (Throwable fe) {
                   startT=0;
                startT+=System.currentTimeMillis();
                timer.start();
          stop.addActionListener(new ActionListener() {
             public void actionPerformed( ActionEvent e ) {
                timer.stop();
          clear.addActionListener(new ActionListener() {
             public void actionPerformed( ActionEvent e ) {
                time.setText("");
          time.setBounds(150,30,100,24);
          time.setOpaque(true);
          time.setBackground(Color.pink);
          getContentPane().add(stop);
          getContentPane().add(start);
          getContentPane().add(time);
          getContentPane().add(combo);
          getContentPane().add(clear);
          timer = new javax.swing.Timer(1000, new ActionListener() {
             public void actionPerformed(ActionEvent e) {
                stopT = System.currentTimeMillis();
                time.setText(timef.format(new Date(startT-stopT)));
          setVisible(true);
       public static void main (String[] args) {
          UIManager.put("Label.font" ,new Font("Times New Roman",0,23));
          UIManager.put("Button.font",new Font("Arial",1,21));
          new Timer1();
    }

    simply the user chooses a time from the combobox say
    1 hour
    and then hits the start button so the timer begins to
    countdown.
    my problem here is i want when the countdown timer
    reaches 0 hour 0 minute 0 second the frame exit (or
    any action)not repeating the default time .
    got it?Ah, yes, now I understand. So when the user chooses an interval, 1 hour in this case, you calculate the number of seconds that make up that interval. (Doesn't have to be seconds, depends on the granularity of the choices) Then you count down that many seconds like I described before. Each time the timer ticks, decrement the counter, and also convert the number of second left back into hours, minues, seconds and display that.
    So the counter becomes the data model that everything's based on, and you format it for display each tick.
    startTimer() {
      int interval = // get the interval selected from the combobox
      int seconds = // convert interval to seconds
      start timer with 1 second period
    actionPerformed() {
       seconds--;
       if (seconds == 0) {
          stop timer
          do whatever we were waiting for
       else {
           convert seconds to HH:MM:SS format and display in gui
    }

  • How convert date/time from xml in xdp(Designer)?

    Hi, i want to convert date/time format from xml in Designer, date/time value in xml is NOT in common format YYYY-MM-DD (if is in a common format i can do this with pattern)
    I have a "DateTime" Field in Xdp can get from Xml date and time:
    In XML <DateTime>DD-MM-YYYY</DateTime> i want to convert in XDP in DateTime Field in "DD-April-YYYY"
    Can i do this?

    You can do this way..
    Bind the date field to your XML tag.
    Set the display pattern for the date field.
    In the initialize event of the date field place the following code.
    Set JavaScript as language.
    var dtStr = this.rawValue;
    var pos1=dtStr.indexOf("-");
    var pos2=dtStr.indexOf("-",pos1+1);
    var strMonth=dtStr.substring(0,pos1);
    var strDay=dtStr.substring(pos1+1,pos2);
    var strYear=dtStr.substring(pos2+1);
    //Assign the formatted value to the Date field.
    this.rawValue = strYear + "-" + strMonth + "-" + strDay;
    Thanks
    Srini

  • How to convert time from (hh:mm:ss) to (hhmmss) in CSV file

    Hi Experts,
    I have a CSV file where there is time column which displays time like hh:mm:ss
    But the input I should give for loading the data is hhmmss
    The amount of records that I have is more than 2 lakhs. I tried many ways to convert the time but I'm unsuccessful.
    Can anyone tell me how do I convert the format please.
    Thanks

    Hi,
    You can create a custom infoobject length 6 (say mytime) to read the data from csv file.
    In the field routine assign the 6 character length info object to the required time IO(system time) with routine.
    Inside the field routine...
    result = source_fields-mytime.
    The system will take care of conversion as per the user master setting.
    Thanks,
    Jugal.

  • How to continue timer from prevous state?

    Hi guys,
    I have some question regarding on the timer. I doing a project called car washing system. Basically every selection will have limited function.
    Example: $2 wash: Heavy Wash (10 sec) -> Air Dry (15 sec )-> Exit
    Example: $5 wash: Main Wash (10sec) -> Soap(10sec) -> Heavy Wash (10sec) -> Air Dry (15 sec) -> Exit
    So for every state the timer run until it reach the timing, the timer will pause and next state the timer will continue. I'm using toggle switch so when i toggle up the timer, it will start running until it reach the stage and pause for next toggle switch up to continue. But currently there is some error which i toggle up the timer get reset.

    You may also want to post questions over on the Certification forum.
    http://forums.ni.com/t5/Certification/bd-p/Certification
    I'd also recommend checking out the elapsed timer express VI.  It doesn't have a pause/resume feature but it doesn't take much to add it.  I started from the express VI and just added this functionality.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • How to subtract dateTime - dateTime

    Does anyone has idea how to subtract in OracleBPEL dateTime - dateTime to get duration? I know only extension function for substracting dateTime - duration (function xp20:subtract-dayTimeDuration-from-dateTime() )

    You have to create your own Xpath function for it. Have a look to this example <ORAHOME>\integration\orabpel\samples\references\CustomXPathFunction

Maybe you are looking for

  • Opening pictures in iPhoto from other programs

    I'm wanting to use pictures from my iPhoto library in other programs-- i.e. Photoshop Elements or to upload to a website. When working from Photoshop Elements, when I go to File>Open>Pictures>iPhotoLibrary I get an error message. The only way I seem

  • Managed System configuration in Solman 7.1 sp11??

    Hi All, I have done new installation of solman 7.1 and upgraded to sp11. I did system preparation and basis configuration in solman_setup. I have one query how to add ERP production system to SLD and how to do managed system configuration for that. I

  • Telephony Server in CCA

    Regarding Telephony Server in CCA: does it include Call center process/conference server process/ Redirect server. Is it a software process or it is a hardware?. If sofware do we download it ? If hardware how is it connected to Telephony server

  • HT1420 Authorizing More than Five Computers

    Why can't use authorize more than five computers? It is driving me crazy!

  • Error when Extracting Metadata from ECC

    Hello, DS 4.2 was working fine with ECC after the creation of RFC connection. I was able to pull some of the tables. but after Basis team made some security changed with the objects, I am not able to pull the metadata from ECC.It is showing the follo