Compare values in different rows for date/time clashing

Hello,
Odd one this so bear with me...
If I'm asking this question in the wrong place I apologise in advance
I'm building a C# application that queries SQL tables, one of the functions I need to be able to implement is the ability to query a row(1) for it's datetime value, and disallow another rows(2) datetime value to be updated if the value of that row(2) is
within an hour of the other row(1).
I hope that makes sense...
Any help will be greatly appreciated!
Thanks
Brendan

Hello,
Thanks for your reply.
Would there be another way to do this?
If there was some way to do this:
UPDATE table SET 'column' VALUES '02/02/2015 14:00' WHERE Date = 02/02/2015 IF 'Column' = 02/02/2015 14:00 OR 02/02/2015 13:00 DENY
I know that's not a proper statement, but you get the idea.
The problem is that the datetime value is likely to change a lot, and I would like to avoid having to change this manually, but if I could somehow check for a datetime value with an hour either side of the update value that would be great.
Thanks
Brendan 

Similar Messages

  • Sum values in last row for date format "hh24:mi"

    Hi,
    I have a big problem creating a sum row with date data.
    I created a sql view where the result looks like that:
    SELECT category_name,
    user_name,
    b_mmyyyy,
    b_1, ..., b_31
    FROM view_category_user_booking
    category_name, user_name, b_1, ..., b_31
    category1, user1, 122008, 01:00, ..., 03:30
    category2, user1, 122008, 02:00, ..., 01:00
    category3, user1, 122008, 00:00, ..., 00:15My goal is to integrate a sum row at the end for the columns b_1 ... b_31
    category_name, user_name, b_1, ..., b_31
    category1, user1, 122008, 01:00, ..., 03:30
    category2, user1, 122008, 02:00, ..., 01:00
    category3, user1, 122008, 00:00, ..., 00:15
    Sum, user1, 122008, 03:00, ..., 04:45I tried it like that:
    select decode(grouping(category_name),1,'Summe',category_name),
    sum(to_number(replace(b_1,':',','))) as b_1,
    sum(to_number(replace(b_31,':',','))) as b_31
    from category_user_booking
    where user_name = 'user1'
    and b_mmyyyy = '122008'
    group by rollup(category_name)But the result isn't really successful
    category_name, b_1, b_31
    category1, 1, 3,3
    category2, 2, 1
    category3, 0, 0,15
    Sum, 3, 4,45Is there somebody with an idea?
    Thanks ahead,
    Tobias

    Hi Avinash,
    the problem is not the grouping it is the date format.
    Instead of a value like 5,4 > I want 05:40 or 1,75 > I want 02:15 in the sum value.
    In my table all time values are saved in the format hh24:mi.
    I don't know how to get that via a sql statement.
    Output I want:
    category_name, user_name, b_1, ..., b_31
    category1, user1, 122008, 01:00, ..., 03:30
    category2, user1, 122008, 02:00, ..., 01:00
    category3, user1, 122008, 00:00, ..., 00:15
    Sum, user1, 122008, 03:00, ..., 04:45Regards,
    Tobias

  • Set default value for date/time to previous month

    Hi All
    I have two date/time parameters in my report and I want to set the default value for both the parameters
    For start date parameter I want the first date of previous month and for end date parameter I want the last date of previous month.
    Can someone please point me to the right direction
    Thanks
    Rone

    Hi Rone,
    These links can be helpful for you:
    http://www.bidn.com/blogs/hardikabhavsar/bidn-blog/1639/default-date-parameters-in-ssrs
    http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/584a98ae-bb75-4740-9198-e6be3c1aec12/
    Regards,
    Manoj
    *Happy to help
    http://experiencingmsbi.blogspot.com/

  • SQL query for date & time interval

    Hello everyone,
    there is my problem
    I have to make a search for events that are taking place during inserted date & time .
    There's the table structure:
    event
    datefrom
    dateto
    timefrom
    timeto
    The problem is, when I try:
    select * from xyz where datefrom <= inserted_date and dateto >= inserted_date and timefrom <= inserted_time and timeto >= inserted time;
    then I don't get back all records.
    eg: user inserts date = 10.10.2010 and time 10:00 and in the table is event [abc 11:00 9.10.2010 -> 09:00 11.10.2010] stored following way:
    event         abdc
    datefrom   09.10.2010
    dateto        11.10.2010
    timefrom    11:00
    timeto         09:00
    => this event won't be found, because the sql logic compares only single parameters and not their context.
    Do you have any idea, how to solve this issue?
    Thank you.
    Lukas

    Hello Hubert,
    thank you very much for your proposal, but your code makes the same select as mine (but in a more user friendly look :).
    Table:
    datefrom 09.10.2010
    dateto 11.10.2010
    timefrom 11:00
    timeto 09:00
    Event date = 10.10.2010 and time 10:00.
    Your query:
    select * from xyz where 10.10.2010 between 09.10.2010 and 11.10.2010 (that's so far ok) and 10:00 between 11:00 and 9:00 (no return there, because 10:00 doesn't lie within interval 11:00 -> 9:00... actually no value lies there) ;
    Don't you have any other idea?
    Thank you
    Lukas

  • Display values in different versions for 3 specific years

    Hi
    I want to show in a dynamic report and in a dynamic input schedule values for different versions ACT and PLAN via Excel client.
    In the rows are entity, time (for 2009, 2010, 2011) and version. And in the columns are special time dimension to show month. Sounds very strange - and it is so... Now I want to show only values for ACT for year 2010 and PLAN for 2011.
    How can I enter the dimension within the expansion area? Is there a way to combine 2 different dimensions like a statement "where time is 2010 and version is ACT"?
    Thank you very much for your ideas

    Hi Nilanjan
    Thank you for your post.
    I'll give EVTIME a try. But it will not solve my problem I guess. EVTIM is helpful for columns to use offset I do understand. Can I use it within expansion area of EVDRE function?
    The display behavior has to be dynamaic. Cause there is in the first expansion dimension entity with a hierarchy. 2.nd expansion is year and 3.rd is version. And I only want to see ACT row for 2009, FC row for 2010 and  PLAN row for 2011. Next 3 rows must be the next item of dimension entity and so on...
    Currently I see 2009 ACT, 2010 ACT and 2011 ACT same like 3 HR and 3 PLAN rows.
    Any ideas?

  • Query to return separate rows for date range including NULLs

    I'm trying to write a query that will return all customers from table 1. Table 1 also provides a start date and an end date that may be different for different customers. Left join with Table 2  provides all matches and NULL if NO matches.
    If there is any match at all, I do not get the NULLs for other dates. There should be a match for each date from start to end. How can I write the code so that my return will loop thru each date and provide the match or NULL?

    Sorry. I am somewhat new to this and am not sure what you are requesting. I receive a return of all customers with the code below but if customer 1 has a start date of 1/1/15 and a stop date of 1/5/15 and a document exists for 1/1/15 and 1/3/15
    I do not receive the rows with NUL for 1/2/15, 1/4/15, and 1/5/15 which is what I'm trying to accomplish. If there is no match at all, I only receive the one row with NULL and I would like to see a row for each date from start to stop.
    SELECT  T1.IDNumber,T1.StartDate,T1.StopDate,T3.SignDateTime
    FROM
    Table1 T1
    INNER
    JOIN Table2
    T2
    ON
    T1.CustID
    = T2.CustID
    LEFT
    JOIN Table3
    T3
    ON
    T1.CustID
    = T3.CustID
    WHERE
    T1.StartDate
    > '2015-01-20 00:00:00.000'
    AND
    (T3.ReportID
    IN ('DOC1',
    'DOC2',
    'DOC3') OR
    T3.ReportID
    IS NULL)
    AND
    T2.YesNo
    = 'Y'

  • How to use value of Report Rows for another Item heading (interesting)

    Hi!
    This seem to be interesting question.
    I have a classic report which has 4 rows with date values. The Row1 has Date1, Row2 has Date2 and so on.
    The report is structured like this
    DATE_COL COL1 COL2
    Row1 Date1 100 101
    Row2 Date2
    I want to use the values of DATE_COL of ROW1 which is Date1 in the label of ITEM1 which can be on same page or different page.
    Also I want to sue the value of DaTE_COL of ROW2 which is Date2 in the label of Column 1 of Report 2.
    How to accomplish this? Appreciate your suggestions.
    Thanks,
    --CP                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    cpora007 wrote:
    Hi!
    This seem to be interesting question.
    I have a classic report which has 4 rows with date values. The Row1 has Date1, Row2 has Date2 and so on.
    The report is structured like this
    DATE_COL COL1 COL2
    Row1 Date1 100 101
    Row2 Date2In your report attributes of DATE_COL column > add column link as follows
    Link Text: #DATE_COL#
    Target Type: URL
    URL: javascript:alert('#DATE_COL#');
    And set the Display as property to Standard Report Column
    Now when the link is clicked you will get the alert with corresponding value
    Next step is to set the value as the label of your item.
    If it is on the same page
    -- Use javascript to set the label
    If its on a different page then you will need to pass this value to that target page and set the label using *&P1_MY_ITEM_NAME.* syntax
    See this to learn how to pass the value in URL http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21674/concept_url.htm#HTMDB03017
    I want to use the values of DATE_COL of ROW1 which is Date1 in the label of ITEM1 which can be on same page or different page.
    Also I want to sue the value of DaTE_COL of ROW2 which is Date2 in the label of Column 1 of Report 2. You can sue if you are in England! :)

  • A question on different options for data archival and compression

    Hi Experts,
    I have production database of about 5 terabyte size in production and about 50 GB in development/QA. I am on Oracle 11.2.0.3 on Linux. We have RMAN backups configured. I have a question about data archival stretegy.  To keep the OLTP database size optimum, what options can be suggested for data archival?
    1) Should each table have a archival stretegy?
    2) What is the best way to archive data - should it be sent to a seperate archival database?
    In our environment, only for about 15 tables we have the archival stretegy defined. For these tables, we copy their data every night to a seperate schema meant to store this archived data and then transfer it eventualy to a diffent archival database. For all other tables, there is no data archival stretegy.
    What are the different options and best practices about it that can be reviewed to put a practical data archival strategy in place? I will be most thankful for your inputs.
    Also what are the different data compression stregegies? For example we have about 25 tables that are read-only. Should they be compressed using the default oracle 9i basic compression? (alter table compress).
    Thanks,
    OrauserN

    You are using 11g and you can compress read only as well as read-write tables in 11g. Both read only and read write tables are the candidate for compression always. This will save space and could increase the performance but always test it before. This was not an option in 10g. Read the following docs.
    http://www.oracle.com/technetwork/database/storage/advanced-compression-whitepaper-130502.pdf
    http://www.oracle.com/technetwork/database/options/compression/faq-092157.html

  • FileMonitor issue for date time stamp change.

    Hi I have an app that runs with a minor issue and I am looking for some insight for a workaround or code change.
    I have a File Monitor that checks a specific directory every second.
    Users send a batch run to this directory throughout the day. There are two types of files, .ZIPs and .DONEs.
    So for each .ZIP a .DONE is sent to notify the app it can begin to process the file.
    Here is what I receive
    /elements/process/File1.ZIP     Oct 15 08:19
    /elements/process/File1.DONE     Oct 15 08:19
    The problem I am encountering is sometimes the .DONE and. ZIP are sent and the date time stamp of both files are the same so when the monitor reads the directory it looks like there is no change so both files sit in the directory and do not process. To make this work, I usually go in and touch a file to change the date time stamp.
    This is a java app that runs on an AIX box.
    Here is my code, is there anything any once can suggest to help me out. Thanks in advance.
       * Subclass of FileMonitor, Handles the timer event
       * @param none
      private class FileMonitorNotifier extends TimerTask
        public void run()
          // Loop over the registered files and see which have changed.
          // Uses the Modifed DateTimeStamp to determine if there was a change.
          // Use a copy of the list in case listener wants to alter the
          // list within its fileChanged method.
            try
                Collection files = new ArrayList (hmFiles.keySet());
                for (Iterator i = files.iterator(); i.hasNext(); )
                    File file = (File) i.next();
                    long lastModifiedTime = ((Long) hmFiles.get (file)).longValue();
                    long newModifiedTime  = file.exists() ? file.lastModified() : -1;
                    //      Check if file has changed
                    if (newModifiedTime != lastModifiedTime)
                        //      Register new modified time
                        hmFiles.put(file, new Long (newModifiedTime));
                        // Notify listeners
                        for (Iterator j = colListeners.iterator(); j.hasNext(); )
                            WeakReference reference = (WeakReference) j.next();
                            FileListener listener = (FileListener) reference.get();
                            // Remove from list if the back-end object has been GC'd
                            if (listener == null)
                                j.remove();
                            else
                                listener.fileChanged (file);
            catch(Exception ex)
                 m_odLaunch.logError(OdIntegrationConstants.ERROR_LEVEL_MIDLEVEL, ex);
         }

    Yes, I guess you are right, I don't care what time each file came, as long as I have both I can being to unzip and process and delete the .DONE.
    The code itself was based on if a filechanged then do work.... I could just take this out. Thanks!
    * This is the main entry point when there is a change to the modified date/time
    *  of the monitor directory
    * @param file directory we are monitoring
         public void fileChanged (File file)
              StringBuffer sbMessage;
              try
                   sbMessage = new StringBuffer();
                   //Make sure this is a Directory
                   if(file.isDirectory())
                        //Return list of files with extension we are looking for
                        File[] arFiles = file.listFiles((FilenameFilter)new FileSuffixMonitor(m_odLauncher));
                        for(int i=0;i < arFiles.length;i++)
                             sbMessage.append("Found file association to move-" );
                             sbMessage.append(arFiles.toString());
                             m_odLauncher.logInstance(sbMessage.toString());
                             processMoveFile(arFiles[i]);
              catch(Exception ex)
              sbMessage = null;

  • For custom tables should we use UTC for date/time fields

    A general question.
    Can anyone confirm that SAP does seem to be moving towards storing date/time in UTC format?
    We're building custom tables and we're making it a standard to store date/time fields in UTC format.
    Regards,
    Lavaughn

    Hello Lavaughn,
    I can not speak for SAP, but from my personal experience TimeStamps are the state of the art to store time date info in db tables. Even with date/Time fields a conversion to the local timezone is necessary. Of course you can reuse your db definition on dynpros. But since UI and business logic will be divided anyway this is also not really a valid point.
    Best Regards
    Klaus

  • Comparing values in different tables

    Hi,
    I am trying to compare values in two different table fields, can someone advise me of the ABAP to do it.
    I need to find IHPA-PARNR(partner number) in table T527X-ORGEH(org unit number)
    Thanks,
    Alec

    OK now I'm confused:
    I put a breakpoint as follows:
    SELECT * FROM t527x INTO TABLE it_t527x.                        
    LOOP AT it_ihpa INTO wa_ihpa.                                   
    READ TABLE it_t527x INTO wa_t527x WITH KEY orgeh = wa_ihpa-parnr
    BINARY SEARCH.                                                  
    IF sy-subrc EQ 0.                                               
    BREAK-POINT.                                                    
    WRITE: wa_t527X-ORGTX TO ZORGUNITTEXT.                          
    ELSE.                                                           
    WRITE: 'Damn it' TO ZORGUNITTEXT.                               
    ENDIF.                                                          
    ENDLOOP.          
    I have the correct values in the correct fields but still SUBRC does not = 0
    WA_T527X-ORGTX                 Stockton - Front of House      
    ZORGUNITTEXT                   Damn it                        
    WA_t527X-ORGEH                 20008855                       
    WA_IHPA-parnr                  20008855                       
    Whats Wrong?
    Edited by: Alec Fletcher on Dec 19, 2008 1:50 PM

  • SQL Query for date/time

    Hi All,
    I have a table containing data like this
    Person_name Time_spent Date/time
    ABC 5.5 16-sep-10 12:00
    ABC 3 16-sep-10 05:30
    ABC 2.5 17-sep-10 12:00
    ABC .5 16-sep-10 09:00
    What I want is to get data like this
    Person_name Time_spent Date/time
    ABC 9 16-sep-10
    ABC 2.5 17-sep-10
    what query i should run?
    Thanx
    Omy

    a query like this ...
    select sum(time_spent), person_name, trunc(date_time) from <table_name>
    group by person_name, trunc(date_time);
    HTH.

  • Looking for a method that reads in a whole row for data rather than using getString();

    Hi,
      I'm using java to read from oracle and Netezza and I'm wondering:
    Is there a method for capturing a row in a variable in order to print that entire row out to a data file or a UNIX file in this case.
    Right now I have this code I'm working with:
      //STEP 4: Execute a query
      System.out.println("Creating statement...");
      stmt = connection.createStatement();
      String sql;
      sql = "SELECT SRC_ID, SRC_CD, SRC_DSC, CKA_SUB_ID FROM SRC";
      ResultSet rs = stmt.executeQuery(sql);
      //STEP 5: Extract data from result set
      while(rs.next()){
    //Retrieve by column name
    String SRC_ID  = rs.getString("SRC_ID");
    String FIRST_ROW  = SRC_ID+", "+SRC_CD+", "+SRC_DSC+", "+CKA_SUB_ID;
    //Display values
    System.out.print("SRC_ID: " + SRC_ID);
    System.out.println(", FIRST_ROW: " + FIRST_ROW);
    Is there a way I can replace the getString with a "getRow"?
    Right now the best I can do is to create and use the FIRST_ROW variable. However I want to be able to do this generically so I can read different tables and write them to data files.
    Thanks!

    Is there a method for capturing a row in a variable in order to print that entire row out to a data file or a UNIX file in this case.
    Is there a way I can replace the getString with a "getRow"?
    No - there is no such 'ROW' entity in Oracle.
    Download and use Oracle's free Sql Developer and you can use a simple query like this:
    select /*csv*/ * from SCOTT.EMP
    That will produce a comma-delimited result set with one record for each row. Then you can save the result set to a file.
    Oracle SQL Developer Downloads
    See this article by Jeff Smith that shows how to get result sets as CSV (and several other) formatted data.
    http://www.thatjeffsmith.com/archive/2012/05/formatting-query-results-to-csv-in-oracle-sql-developer/

  • In process order confirmation screen there should be 2 rows for down time.

    hi,
    We are using cor6n for process order confirmation, where we can put down time  with confirmation text at once,
    if there is two different down time, then user has to again  run cor6n with 0 yield  for put another down time, which gets more time.
    for this reason i have customised single screen entry profile by mentioning two down time & confirmation rows in screen.
    when i going for confirmation i put two different down time  after goods movemnt order get confirmed & settled.
    but when i see report in COOISPI  there is only one down time against order.
    system only considers last down time.
    hows the system consider down time?
    thanks in advance.
    regards
    sanjay.

    Hi,
    The report COOISPI considers only one line of the down time, it is not considering the 2nd row of the down time. You need to change the COOISPI program to read the 2 lines of the down time. You need to change the standard program to read the 2 down time lines.
    Thanks & Regards,
    V. Suresh

  • Function Module for Date/ Time difference in Working Days

    Hi all,
    Are there any function modules which will calculate the difference between a date AND time, but in working days?
    I can use the FIMA_DAYS_BETWEEN_TWO_DATES_2 FM for the dates, but I need to include times in this as well.
    This is for situations where the 'starting date' is a non-working day, and the 'end date' is a working day.  In this situation I need to take all the hours and minutes into account, which happened on the working day.  To give an example -
    Start date:  04.07.2010 (Sunday - Non working day)
    Start time:  21:12:36
    End date:  05.07.2010 (Monday - Working day)
    End time:  04:47:24
    I realise there is a Time option in this function module, but when I test it, it doesn't seem to be returning the desired results (returns 0 for days and time).  I am using '5' as the I_STGMETH and 'GB' as the I_SKALID. 
    I need a calcuation which will return the time, post midnight on the working day - in this example, 4 hours, 47 minutes (seconds are optional!).
    Can anyone help? - can I still use FIMA_DAYS_BETWEEN_TWO_DATES_2 but with different parameters?
    Thanks
    Mischa
    Edited by: Mischa Gulseven on Jul 20, 2010 10:40 AM

    Hi,
    Thanks but this FM does not seem to account for working days.
    For example, if I use:
    DATE1                           04.07.2010  (non working day)
    TIME1                           04:00:00
    DATE2                           05.07.2010   (working day)
    TIME2                           21:00:00
    It will give the following results -
    DATEDIFF                                                      1
    TIMEDIFF                                                     17
    EARLIEST                        1
    I don't want to account for the non-working day so the result I actually want would be to calculate from midnight on 05.07 to 21:00 on 05.07 which should be 21 hours.
    I suspect I probably need to include the STGMETH and the factory calendar somewhere in the FM?
    Does such a FM exist, or could anyone help me with some ABAP for this?
    thanks
    Mischa

Maybe you are looking for

  • ERROR While Accessing the DATABASE

    Hi all, when i try to login to the db its showing an error..... bsa0048:l0madm 72> dbmcli -d <SID> -u control,PWD db_state Error! Connection failed to node (local) for database SID: -24700,ERR_DBMSRV_NOSTART: Could not start DBM server. -24832,ERR_SH

  • HP Laserjet 1020 connected to Airport Express - Can't Print from Windows XP

    Hi, I have been using Airport Express for almost a year now, and it works fine with my old LaserJet 1200 connected to it, meaning that BOTH my ThinkPad(WinXP) and PowerBook(OSX 10.3) prints off the printer nicely. Last week I bought a LaserJet 1020 t

  • How to setup a 'duplicate/mirror view' with a different zoom level?

    Hi Photoshop Gurus, I constantly keep zooming in and out of the same images. It drives me crazy to view it at normal zoom level and zoom back into deep pixels. Is there a way so that I have a duplicate floating window/view that shows realtime editing

  • Controlling multiple iPads for a presentation

    Just wondering if anyone knows of a good method to run a presentation on multiple ipads simultaneously? I'd like to hand out iPads at a boardroom meeting and control them all from a central device. Thanks

  • At selection-screen. - message - go back to the field on selection-screen

    At selection-screen. If the user enter the wrong profitcenter . just  I  need to issue a  message saying the user to "enter the correct profit center " and cursor should go back to the profit center field on the selection screen. How to code this ?