APEX - SQL Workshop - SQL Commands : Issue in extracting hour from date

Hello All,
When I run
SELECT to_char(sysdate,'hh24') from DUALon SQL Developer and APEX SQL Commands window, both are returning correct hour value.
But when I run
SELECT to_char(i_date,'hh24') from t_factthen I'm getting correct values in SQL Developer but not in APEX SQL Commands window. In APEX, it always returns '00' for all rows. I'm totally lost what could be the issue with APEX? Any suggestions?
DB Version: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
APEX Version: 4.0.1.00.03
Web Server : EPG
Table structure:
CREATE TABLE  "T_FACT"
   (     "TF_KEY" NUMBER,
     "TOWER" VARCHAR2(20),
     "LOC_ID" NUMBER,
     "TF_CAT" VARCHAR2(35),
     "EQP_NAME" VARCHAR2(35),
     "I_DATE" DATE,
     "MON_CATEGORY" VARCHAR2(35),
     "EVENT" VARCHAR2(35),
     "UNIT" VARCHAR2(35),
     "TF_VALUE" NUMBER
   );Regards,
Hari

Hi,
Just silly question case you have same table in multiple schemas:
You run query in same schema?
Regards,
Jari

Similar Messages

  • Problems While Extracting Hours From Date Field

    Hi Guys,
    Hope you are doing well.
    I am facing some problems while extracting hours from date field. Below is an example of my orders table:-
    select * from orders;
    Order_NO     Arrival Time               Product Name
    1          20-NOV-10 10:10:00 AM          Desktop
    2          21-NOV-10 17:26:34 PM          Laptop
    3          22-JAN-11 08:10:00 AM          Printer
    Earlier there was a requirement that daily how many orders are taking place in the order's table, In that I used to write a query
    arrival_time>=trunc((sysdate-1),'DD')
    and arrival_time<trunc((sysdate),'DD')
    The above query gives me yesterday how many orders have been taken place.
    Now I have new requirement to generate a report on every 4 hours how many orders will take place. For an example if current time is 8.00 AM IST then the query should fetch from 4.00 AM till 8 AM how many orders taken place. The report will run next at 12.00 PM IST which will give me order took place from 8.00 AM till 12.00 PM.
    The report will run at every 4 hours a day and generate report of orders taken place of last 4 hours. I have a scheduler which will run this query every hours, but how to make the query understand to fetch order details which arrived last 4 hours. I am not able to achieve this using trunc.
    Can you please assist me how to make this happen. I have checked "Extract" also but I am not satisfied.
    Please help.
    Thanks In Advance
    Arijit

    you may try something like
    with testdata as (
      select sysdate - level/24 t from dual
      connect by level <11
    select
      to_char(sysdate, 'DD-MM-YYYY HH24:MI:SS') s
    , to_char(t, 'DD-MM-YYYY HH24:MI:SS') t from testdata
    where
    t >= trunc(sysdate, 'HH') - numtodsinterval(4, 'HOUR')
    S     T
    19-06-2012 16:08:21     19-06-2012 15:08:21
    19-06-2012 16:08:21     19-06-2012 14:08:21
    19-06-2012 16:08:21     19-06-2012 13:08:21
    19-06-2012 16:08:21     19-06-2012 12:08:21trunc ( ,'HH') truncates the minutes and seconds from the date.
    Extract hour works only on timestamps
    regards
    Edited by: chris227 on 19.06.2012 14:13

  • Issue in moving files from data fodler to processed folder in background

    Hi All,
    I am facing one issue in moving files from data fodler to processed folder in case of background execution.
    When i am executing the file in the foreground, i can move the file from Data folder to processed folder. I am using SXPG_COMMAND_EXECUTE FM to move the file from data folder to processed folder.  I can see the file in processed folder once the program is executed.
    But in case of executing the same program in background, it is giving me the error "Failed to move the file to processed folder" in the spool of SM37 and i can see the file still laying in data folder.
    I tried to check other programs which acesses the same folder as the above program, whether they are able to move. They are able to move the file to processed fodler successfully both in foreground and background mode.
    Please help me in resolving this issue.
    Thanks,
    Deepa

    Hi Sanu,
                    Please use teh following code to move the file from source to target folder.
    This is a code showing how to create and use COPY command of UNIX in ABAP
    PARAMETERS:
    Input file path
    p_input TYPE localfile,
    Processed file path
    p_proc TYPE localfile.
    Declare the Types to file data
    TYPES: BEGIN OF L_X_OUTPUT,
    sys(200), " Please note, there are asterisk before and after sys (i.e.sys)
    END OF L_X_OUTPUT.
    * Internal table to store file data
    DATA l_i_output TYPE STANDARD TABLE OF l_x_output WITH HEADER LINE.
    * Variable for the UNIX command
    DATA: l_v_unix_comm(255) TYPE c.
    Copy command of UNIX
    CONCATENATE 'mv' p_input p_proc
    INTO l_v_unix_comm SEPARATED BY space.
    For example the Copy command is stored as below
    cp u2018/data/interfaces/input/input_fileu2019 u2018/data/interfaces/processed/processed_fileu2019
    Examples of UNIX Command *u2022 mv filename1 filename2 --- moves a file (i.e. gives it a different name, or moves it into a *different directory (see below) *u2022 cp filename1 filename2 --- copies a file
    Execute the UNIX Copy command.
    This command will copy the file from input file path to the processed file path
    CALL 'SYSTEM' ID 'COMMAND' FIELD l_v_unix_comm
    ID 'TAB'
    FIELD l_i_output-sys.
    IF sy-subrc eq 0.
    write: 'File is copied successfully using UNIX command in ABAP'.
    ENDIF.

  • Use SQL Workshop SQL Scripts function

    When I tried the following 5 steps,
    I cannot enter the ddl in the SQL editor window.
    The fact is that I cannot enter anything.
    Anyone can point out what is wrong with my procedure??????
    Thanks!
    Create the HT_EMP Table
    To create the HT_EMP table and the appropriate associated objects:
    1. Click SQL Workshop on the Workspace home page.
    2. Click SQL Scripts.
    3. When the SQL Scripts Repository appears, click Create.
    The Script Editor appears.
    4. In Script Name, enter HT_EMP
    5. In the Script Editor, enter the following DDL:
    CREATE TABLE ht_emp (
    emp_id NUMBER primary key,
    emp_first_name VARCHAR2(30) not null,
    emp_middle_initial VARCHAR2(1),
    emp_last_name VARCHAR2(45) not null,
    emp_part_or_full_time VARCHAR2(1) not null check (emp_part_or_full_time in
    ('P','F')),
    emp_salary NUMBER,
    emp_dept VARCHAR2(20) check (emp_dept in
    ('SALES','ACCOUNTING',
    'MANUFACTURING','HR')),
    emp_hiredate DATE,
    emp_manager NUMBER references ht_emp,
    emp_special_info VARCHAR2(2000),
    emp_telecommute VARCHAR2(1) check (emp_telecommute in ('Y')),
    rec_create_date DATE not null,
    rec_update_date date)
    /

    You need to upload the file to the SQL scripts area of ApEx. If you upload it to the static files area it's not going to be treated as a SQL script.
    Barring that as the problem - did you verify the contents of the script file on your workstation before you uploaded it - to make sure that the script actually contained the correct contents of the script?
    I've never had any significant problems with script uploads and running scripts in ApEx that couldn't be traced back to operator error. :>)
    Try explaining in detail the steps that you took to try to make this work - then we'll know where to start.
    Earl
    Message was edited by:
    Earl

  • Extract Quarter from date cell

    I'm trying to extract Year Quarters from date column (A) with no luck.
    I've tried:
    =Int((Month(A1) + 2) / 3)
    but nothing happens. This formula works in Excel & Filemaker.
    Any ideas?

    Hello
    I'm really surprised because on my french version it works::
    =ENT((MOIS(A1)+2)/3)
    returns 4 with my birthday (31/12/1943)
    Yvan KOENIG (from FRANCE lundi 17 septembre 2007 20:20:21)

  • Extract year from date

    Hello,
    Iam using obiee 11g, would like to extract the year from date
    CAST(YEAR("ABC"."DATEADDED" ) as varchar(4))
    so used like this
    But i want like if the year is 2011 then only 11 i wants is there a direct function which does that.
    Thanks

    You can use the right function right(year, 2). Will return 11 if year is 2011

  • Bug in SQL Workshop, SQL Scripts, Results page [Apex 4.0.1.00.03]

    I have some scripts that I have created to insert various rows into a table called level5. Most rows execute properly and the output shows "1 row inserted" as I would expect.
    But then some others give bizarre output on the Results page. Here are a few examples (first 2 are what I would term "correct", the rest are "odd"):
    1 0.27 insert into level5 (name, description, active, approver_id, 1 row(s) inserted. 1
    2 0.02 insert into level5 (name, description, active, approver_id, 1 row(s) inserted. 1
    33 0.02 insert into level5 (name, description, active, approver_id, Statement processed. 1
    58 0.02 insert into level5 (name, description, active, approver_id, Statement processed. 1
    65 0.03 insert into level5 (name, description, active, approver_id, User created. 1
    633 0.05 insert into level5 (name, description, active, approver_id, Role created. 1
    924 0.02 insert into level5 (name, description, active, approver_id, Role created. 1
    The SQL across these various rows is identical except for some values in varchars.
    Here are the corresponding sql commands:
    1
    insert into level5 (name, description, active, approver_id, level4_id) values ('M_SECROLE', 'Security', '1', (select id from persons where pernr='376' and active='1'), (select id from level4 where name='SD1' and level3_id=(select id from level3 where name='xyz' and level2_id=(select id from level2 where name='clienta' and level1_id=(select id from level1 where name='Application')))));
    2
    insert into level5 (name, description, active, approver_id, level4_id) values ('M_ADMIN', 'ADMIN', '1', (select id from persons where pernr='376' and active='1'), (select id from level4 where name='SD1' and level3_id=(select id from level3 where name='xyz' and level2_id=(select id from level2 where name='clienta' and level1_id=(select id from level1 where name='Application')))));
    33
    insert into level5 (name, description, active, approver_id, level4_id) values ('COLL_CREAT_RM', 'Collaboration Create Room', '1', (select id from persons where pernr='327' and active='1'), (select id from level4 where name='SD1' and level3_id=(select id from level3 where name='xyz' and level2_id=(select id from level2 where name='clienta' and level1_id=(select id from level1 where name='Application')))));
    58
    insert into level5 (name, description, active, approver_id, level4_id) values ('360_FEEDBACK', '360 Feedback', '1', (select id from persons where pernr='327' and active='1'), (select id from level4 where name='SD1' and level3_id=(select id from level3 where name='xyz' and level2_id=(select id from level2 where name='clienta' and level1_id=(select id from level1 where name='Application')))));
    65
    insert into level5 (name, description, active, approver_id, level4_id) values ('AUTO_USER_ADM', 'Automated User Admin', '1', (select id from persons where pernr='702' and active='1'), (select id from level4 where name='DD1' and level3_id=(select id from level3 where name='xyz' and level2_id=(select id from level2 where name='clienta' and level1_id=(select id from level1 where name='Application')))));
    633
    insert into level5 (name, description, active, approver_id, level4_id) values ('PROD_SUPPORT_CRE_INV', 'IT SRM Prod Support Role Create Invoices', '1', (select id from persons where pernr='990' and active='1'), (select id from level4 where name='PC1' and level3_id=(select id from level3 where name='xyz' and level2_id=(select id from level2 where name='clienta' and level1_id=(select id from level1 where name='Application')))));
    924
    insert into level5 (name, description, active, approver_id, level4_id) values ('PROD_SUPPORT_CRE_INV', 'IT SRM Prod Support Role Create Invoices', '1', (select id from persons where pernr='327' and active='1'), (select id from level4 where name='QC1' and level3_id=(select id from level3 where name='xyz' and level2_id=(select id from level2 where name='clienta' and level1_id=(select id from level1 where name='Application')))));
    Basically it looks to me like the results text is somehow being affected by the text in my description colum in my SQL. This seems wrong to me, and a bug. Why don't they all just show the same "1 row inserted" text? Why do some say "statement processed"? And why the User and Role created -- that is just plain wrong!
    Would you agree this is a bug??
    This is on Application Express 4.0.1.00.03 in case that matters!

    Hi,
    Browser: Firefox 3.6.13 and IE 8.0
    Template: One Level Tabs - Right Sidebar (optional / table-based)
    Theme: 2. Builder Blue
    Here is an application I created on http://apex.oracle.com.
    http://apex.oracle.com/pls/apex/f?p=29067:1
    Workspace: abc
    User ID: [email protected]
    Password: ssddaa05
    Please look at this application and help me to get the SAL column in RED font when SAL>2000.
    Thanks
    Chandra.
    Edited by: Chandra on Jan 11, 2011 12:38 PM

  • SQL Workshop - SQL Commands - Saved SQL:  Saved set of commands

    Has any thought been given to this, or perhaps this has already been done.....
    A saved set of SQL commands as a template
    For example, when I'm in Excel and I start writing a lookup formula, a guide appears below the cell, reminding me of the format of what comes next. When I know what I'm doing, I simply ignore the guide. When I don't know what I'm doing, the guide is helpful - even linkable to more information.
    Perhaps there are too many variables here to do that....
    In the meantime, I'm creating my own 'set' as I learn - perhaps that's even better.
    Marion in NY

    Hi Kirsten,
    this could be controlled at the database level whereby you create a schema that doesn't own the objects your users are querying but has the appropriate grants and privileges made to it and synonyms or views created to represent the objects. This schema then becomes the parsing schema for the workspace you let your users use. This wont prevent them from creating update statements, but at the database level it will not allow them to be executed.
    Regards
    Andre

  • ADF Libary Issue - Application Module disappear from data control

    Hi All,
    I am facing an issue while adding an Application module to an ADF project as an ADF libray.
    I have two applications - ADF Application1 with Model1 project having an Application module AM1, ADF Application2 with Model2 project having an Application Module AM2
    I have created an ADF library jar file of Model1 project.
    When I add it to Model2 project, the Application Module AM2 of Model2 disappears and Application Module AM1 from the library appears in data control.
    Please suggest what could be wrong.
    Regards,
    Rekha

    Hi,
    verify that both application modules don't share the same ID in their databindings.cpx file. Which release version of JDeveloper 11g are you on ?
    Frank

  • Extracting month from date

    hi,
    I have a query in Informix which get the month part of a date. Please help me in converting the same to oracle.
    Informix query
    select month(col1 - today) from tab1;
    col1 is a date field, today will yield the current date and month function will get the month of the date.
    In oracle, when we subtract two dates we will get a number value, how to convert that back to date and extract the month part.
    Help me?????
    Regards,
    Gopu

    select months_between(sysdate, col1)
    from tab1;
    This will return a decimal value representing the months and part month between the two periods. The later date should be specified first, or the result will be a negative value.

  • Issues while manually exporting from Data Manager

    Hi Guru's,
    When we try to export dat in Excel Or Text OR Access and select/tick Qualifiers for exporting then "Split qualified lookup fields into multiple rows" gets ticked automatically and greys it out,so cant even untick it......
    This causes issues as we want the whole data of record to come in single row  and not in multiple row..
    Any idea/setting which can fix this..
    Regards
    Vikrant M kelkar

    Hi Vikrant,
    This is the default behaviour. You can check the same from the below link
    http://help.sap.com/saphelp_mdm550/helpdata/en/43/e0677c82b40a2ee10000000a11466f/frameset.htm
    Exporting Records -> Exporting Table Records -> Qualifier and Qualified lookup field export
    Regards,
    Jitesh Talreja

  • Extracting time from date and adding it to another date.

    Dear All,
    The values of two fields in my table are as follows:
    n_date n_time
    12/7/2007 1/1/1970 5:50:23 PM
    Both of these fields are of date data type.
    How can i add the time from n_time to n_date so that n_date will reflect a date with time added?
    The problem is that i want to sort on n_date and i am not getting result when two dates are having same values for n_date but different for n_time.
    How can i create a new expression for sorting these values?
    Thanks in advance.
    Regards,
    Sameer

    Hi,
    Check this.
    with data as
    ( select to_date('12/7/2007','dd/mm/yyyy') as ndate, to_date('1/1/1970 5:50:23','dd/mm/yyyy hh24:mi:ss') ntime from dual)
    select ndate + (ntime - trunc(ntime)) from data
    Regards
    RK

  • Extract Time from date and Time and Need XLMOD Funtion to find the Difference between Two Time.

    X6 = "1/5/15 5:16 AM" & NOW ....................difference by Only Time
    not date
    X6 date and Time will be changing, Its not Constant
                Dim myDateTime As DateTime = X6
                Dim myDate As String = myDateTime.ToString("dd/MM/yy")
                Dim myTime As String = myDateTime.ToString("hh:mm tt")
                Dim myDateTime1 As DateTime = Now
                Dim myDate1 As String = myDateTime1.ToString("dd/MM/yy")
                Dim myTime1 As String = myDateTime1.ToString("hh:mm tt")
    Need to use this function to find the Difference between Two Time. due to 12:00 AM isuue
    Function XLMod(a, b)
        ' This replicates the Excel MOD function
        XLMod = a - b * Int(a / b)
    End Function
    Output Required
     dim dd  = XLMod(myTime - myTime1)
    Problem is myTime & myTime1 is String Need to convert them into Time, Later use XLMOD Funtion.

    Induhar,
    As an addendum to this, I thought I'd add this in also: If you have two valid DateTime objects you might consider using a class which I put together a few years ago
    shown on a page of my website here.
    To use it, just instantiate with two DateTime objects (order doesn't matter, it'll figure it out) and you'll then have access to the public properties. For this example, I'm just showing the .ToString method:
    Option Strict On
    Option Explicit On
    Option Infer Off
    Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.Load
    Dim date1 As DateTime = Now
    Dim date2 As DateTime = #1/1/1970 2:35:00 PM#
    Dim howOld As New Age(date1, date2)
    MessageBox.Show(howOld.ToString, "Age")
    Stop
    End Sub
    End Class
    I hope that helps, if not now then maybe at some point in the future. :)
    Still lost in code, just at a little higher level.
      Thanx frank, can use this in Future....

  • Extract year from date and exclude Null

    I have a calculated column that will pull the year out of a date column:
    =TEXT([Date Impact Identified],"yyyy")
    This formula works fine but if the column is blank then it returns the value as 1899. I have tried several variations of ISBLANK or ="" but nothing has worked so far. I think I am putting the formula in the wrong order. Can anyone help?
    Thanks.

    Hello,
    In order to save you weeding through other threads, here's what should work in your scenario:
    =IF(ISBLANK([Date
    Impact Identified]),"",TEXT([Date
    Impact Identified],"yyyy"))
    cheers, teylyn

  • Run procedure from SQL Workshop Command window?

    hi, this one is simple.
    how to run a created procedure from APEX SQL Workshop SQL Command window?
    simon

    Simon,
    begin [proc_name]; end;
    -Carsten

Maybe you are looking for