Get previous bill date using SQL

Hi,
I am table which holds records for bill generation. I have column name gene_bill_date which is date field and it holds a value the date on which the particular bill was generated.
Now I am trying to get previous bill date, not the current bill date. I can to Max(gene_bill_date) to get current bill date, but how do I get previous bill date?
thanks

Hi,
Sorry, it's unclear what you're asking.
You didn't post any sample data, so I'll use the scott.emp table to illustrate. Let's say we're interested in deptno=30 only, just to reduce the output from 14 rows to 6.
If, for every row, you need to know the most recent gene_bill_date before the one on that row, you can do something like this:
SELECT     ename
,     hiredate
,     LAG (hiredate) OVER (ORDER BY hiredate)     AS prev_hiredate
FROM     scott.emp
WHERE     deptno     = 30
;Output:
ENAME      HIREDATE    PREV_HIREDA
ALLEN      20-Feb-1981
WARD       22-Feb-1981 20-Feb-1981
BLAKE      01-May-1981 22-Feb-1981
TURNER     08-Sep-1981 01-May-1981
MARTIN     28-Sep-1981 08-Sep-1981
JAMES      03-Dec-1981 28-Sep-1981Are you only interested in the 2 most recent dates in the whole result set?
If so, do a Top-N Query , like this:
WITH     got_r_num     AS
     SELECT     ename
     ,     hiredate
     ,     RANK () OVER (ORDER BY hiredate  DESC)     AS r_num
     FROM     scott.emp
     WHERE     deptno     = 30
SELECT     *
FROM     got_r_num
WHERE     r_num     <= 2
;Output:
ENAME      HIREDATE         R_NUM
JAMES      03-Dec-1981          1
MARTIN     28-Sep-1981          2 
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using.

Similar Messages

  • Get a date using Sql

    hi
    how i can get the following date using sql, ie i want to get '01-APR-2005'
    if the sysdate is between (01/04/2005 - 31/3/2006). in the same way if it is
    01/04/2004 - 31/3/2005 i want to get '01-apr-2004'...in the same way for any year..
    how i can get this...
    thx in adv
    Kris
    Message was edited by:
    Kris

    SQL> select dt, add_months(trunc(add_months(dt, -3), 'yyyy'), 3) new_dt
      2    from t
      3   order by dt;
    DT        NEW_DT
    01-APR-04 01-APR-04
    31-DEC-04 01-APR-04
    01-JAN-05 01-APR-04
    31-MAR-05 01-APR-04
    01-APR-05 01-APR-05
    31-DEC-05 01-APR-05
    01-JAN-06 01-APR-05
    31-MAR-06 01-APR-05
    8 rows selected.
    SQL> select add_months(trunc(add_months(sysdate, -3), 'yyyy'), 3) from dual;
    ADD_MONTH
    01-APR-05

  • How to get previous day data if i dont have current day data.

    Hello Gurus,
    I have a stock levels data in ODS. when there is no movements, we are not getting any stocks into ODS. So we have to get previous day data as it is for current day data into another ODS.
    Could you please help me in this regard.
    Thanks in advance,
    Rama

    Rama -    
            0CALDAY can't help us in this scenario .
    Step 1 :
        To do this - You have to add one ZDATE (InfoObject ) to 1st ODS. ZDATE is updated by itself from current date of system  when ever you are loading data to 1st ODS.
    Step 2:
       You have to do full update to 2nd ods.At the selection screen of InfoPackage  (from 1st ODS to 2nd ODS ) you have to write following code for ZDATE.
    pseudo Code:
    1) Select fields "Rec_INSERT","Time stamp","Request Status" and "Request ID"  where ICUBE = ODS1 from table "RSMONICDP"
    2) Populate above selected fields data in INTERNAL TABLE
    3) Sort INTERNAL TABLE by Time stamp .
    4)
         If (Record Count = ' 0 ' for current date in internal table )
         update records from  ODS1 to ODS2 where ZDATE = "yesterday date"
         else
         update records from ODS1 to ODS2 where ZDATE= "today date"
         endif.
    Make sure this is full update not delta update from ODS1 to ODS2
    I am sorry, I m not good in Coding but I am sure if  u use this logic,You can meet your requirement.
    I hope you can understand my logic. Let me know if you have any questions,
    Anesh B .

  • Loading data with dates using SQL*Loader

    Dear everyone
    I am currently trying to load some data containing dates using SQL*Loader.
    For termination of fields I have been using ^ because I have some book titles which contain " and ' as part of their title. I found that the TO_DATE function did not seem to work using ^ instead of ". Would I be correct? I think the Oracle manual says that " must be used.
    After some Web research I eventually amended my control file to as follows:
    load data
    infile 'h:\insert_statements\22_insert_into_SCAN_FILE_INFO.txt'
    REPLACE
    into table SCAN_FILE_INFO
    fields terminated by "," optionally enclosed by '^'
    TRAILING NULLCOLS
    (scan_id, scan_filename
    file_format_id
    orig_scanning_resolution_dpi
    scanner_id, scanner_operator_id
    scanning_date "TO_DATE (:scanning_date, 'YYYY-MM-DD')"
    original_map_publication_id
    reprint_publication_id)
    A simple line of data is as follow:
    280001, ^1910 - London^, 270001, 400, 250001, 260001, "TO_DATE('2007-06-06', 'YYYY-MM-DD')", 200019,
    The final column being null.
    However when I attempt that I get the following error message:
    Record 1: Rejected - Error on table SCAN_FILE_INFO, column SCANNING_DATE.
    ORA-01841: (full) year must be between -4713 and +9999, and not be 0
    If I change the scanning_date part to:
    scanning_date "EXPRESSION TO_DATE (:scanning_date, 'YYYY-MM-DD')",
    or
    scanning_date "CONSTANT TO_DATE (:scanning_date, 'YYYY-MM-DD')",
    I get the error message:
    Record 1: Rejected - Error on table SCAN_FILE_INFO, column SCANNING_DATE.
    ORA-00917: missing comma
    As soon as I do the following:
    scanning_date "EXPRESSION, TO_DATE (:scanning_date, 'YYYY-MM-DD')",
    or
    scanning_date "CONSTANT, TO_DATE (:scanning_date, 'YYYY-MM-DD')",
    I get too many values error message:
    Record 1: Rejected - Error on table SCAN_FILE_INFO.
    ORA-00913: too many values
    I also tested out scanning_date DATE "YYYY-MM-DD", but that just gave the same ORA-01841 error message as above.
    I must be doing something very simple which is wrong but I cannot figure it out.
    Kind regards
    Tim

    And why do you have scanning date as "TO_DATE('2007-06-06', 'YYYY-MM-DD')" in your infile? All you need is 2007-06-06. If you can not change infile generation code, use:
    load data
    infile 'h:\insert_statements\22_insert_into_SCAN_FILE_INFO.txt'
    REPLACE
    into table SCAN_FILE_INFO
    fields terminated by "," optionally enclosed by '^'
    TRAILING NULLCOLS
    (scan_id, scan_filename
    file_format_id
    orig_scanning_resolution_dpi
    scanner_id, scanner_operator_id
    scanning_date "TO_DATE(REPLACE(REPLACE(:scanning_date,'TO_DATE('),'''YYYY-MM-DD'')'), 'YYYY-MM-DD')"
    original_map_publication_id
    reprint_publication_id)SY.

  • How to get the context data using java script in interactive forms

    Hi All,
    How to get the context data using java script in interactive forms by adobe,  am using web dynpro java
    thanks.

    Hi venkat,
    Please Refer this link.
      Populating one Drop-Down list from the selection of another Drop-down list
    Thanks,
    Raju.

  • How to view clob data using sql

    Hi,
    In our database, we have one table that is having one column of CLOB datatype but now i want to view the data using sql select query but it throws error: "Datatype not supported".
    Could any one please let me know how to view the clob data using select query.
    Oracle DB version : 10.2.0.3
    Thanks

    h5.
    use read procedure
    PROCEDURE READ (
    lobsrc IN BFILE|BLOB|CLOB ,
    amount IN OUT BINARY_INTEGER,
    offset IN INTEGER,
    buffer OUT RAW|VARCHAR2 );
    example  Updating LOB by Using DBMS_LOB in PL/SQL
    DECLARE
    lobloc CLOB; -- serves as the LOB locator
    text VARCHAR2(32767):='Resigned: 5 August 2000';
    amount NUMBER ; -- amount to be written
    offset INTEGER; -- where to start writing
    BEGIN
    SELECT resume INTO lobloc
    FROM employees
    WHERE employee_id = 405 FOR UPDATE;
    offset := DBMS_LOB.GETLENGTH(lobloc) + 2;
    amount := length(text);
    DBMS_LOB.WRITE (lobloc, amount, offset, text );
    text := ' Resigned: 30 September 2000';
    SELECT resume INTO lobloc
    FROM employees
    WHERE employee_id = 170 FOR UPDATE;
    amount := length(text);
    DBMS_LOB.WRITEAPPEND(lobloc, amount, text);
    COMMIT;
    END;

  • Can we change the system date using Sql

    can we change the system date using Sql statement..
    can anyone help
    Tariq.

    There is an initialization parameter called FIXED_DATE which lets you set a fixed sysdate for testing purposes, and you can alter that date using the ALTER SYSTEM command, but as implied by the name you are setting a data/time that doesn't change. Since the normal sysdate is derived from the O/S it cannot be altered through SQL

  • How can I validate a date using sql

    How can I validate a date using sql or pl/sql
    select to_date('01/01/2009','mm/dd/yyyy') from dual this is a good date
    but how can I check for a bad date
    select to_date('0a/01/2009','mm/dd/yyyy') from dual
    Howard

    William Robertson wrote:
    It'll be complicated in pure SQL, as you'll have to parse out day, month and year and then validate the day against the month and year bearing in mind the rules for leap years. It would be simpler to write a PL/SQL function and call that.Nah, not that complicated, you just need to generate a calender to validate against.
    SQL> ed
    Wrote file afiedt.buf
      1  with yrs as (select rownum-1 as yr from dual connect by rownum <= 100)
      2      ,mnth as (select rownum as mn, case when rownum in (4,6,9,11) then 30
      3                            when rownum = 2 then 28
      4                       else 31
      5                       end as dy
      6                from dual
      7                connect by rownum <= 12)
      8      ,cent as (select (rownum-1) as cen from dual connect by rownum <= 21)
      9      ,cal as (select cen, yr, mn,
    10                      case when ((yr = 0 and mod(cen,400) = 0)
    11                             or (mod(yr,4) = 0 and yr > 0))
    12                            and mn = 2 then dy+1
    13                      else dy
    14                      end as dy
    15               from cent, yrs, mnth)
    16  --
    17      ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    18  --
    19  select case when cal.cen is null then 'Invalid Date'
    20              when not regexp_like(dt,'^[0-9]{1,2}[\/.-_][0-9]{1,2}[\/.-_][0-9]{4}$') then 'Invalid Date'
    21         else dt
    22         end as dt
    23  from dt left outer join
    24               cal on (to_number(regexp_substr(dt,'[0-9]+')) between 1 and cal.dy
    25                   and to_number(regexp_substr(dt,'[0-9]+',1,2)) = cal.mn
    26                   and floor(to_number(regexp_substr(dt,'[0-9]+',1,3))/100) = cal.cen
    27*                  and to_number(substr(regexp_substr(dt,'[0-9]+',1,3),-2)) = cal.yr)
    SQL> /
    Enter value for date_dd_mm_yyyy: a1/02/2008
    old  17:     ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    new  17:     ,dt as (select 'a1/02/2008' as dt from dual)
    DT
    Invalid Date
    SQL> /
    Enter value for date_dd_mm_yyyy: 01/02/2008
    old  17:     ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    new  17:     ,dt as (select '01/02/2008' as dt from dual)
    DT
    01/02/2008
    SQL> /
    Enter value for date_dd_mm_yyyy: 29/02/2008
    old  17:     ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    new  17:     ,dt as (select '29/02/2008' as dt from dual)
    DT
    29/02/2008
    SQL> /
    Enter value for date_dd_mm_yyyy: 30/02/2008
    old  17:     ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    new  17:     ,dt as (select '30/02/2008' as dt from dual)
    DT
    Invalid Date
    SQL> /
    Enter value for date_dd_mm_yyyy: 29/02/2009
    old  17:     ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    new  17:     ,dt as (select '29/02/2009' as dt from dual)
    DT
    Invalid Date
    SQL> /
    Enter value for date_dd_mm_yyyy: 28/02/2009
    old  17:     ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    new  17:     ,dt as (select '28/02/2009' as dt from dual)
    DT
    28/02/2009
    SQL> /
    Enter value for date_dd_mm_yyyy: 0a/01/2009
    old  17:     ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    new  17:     ,dt as (select '0a/01/2009' as dt from dual)
    DT
    Invalid Date
    SQL> /
    Enter value for date_dd_mm_yyyy: 00/01/2009
    old  17:     ,dt as (select '&date_dd_mm_yyyy' as dt from dual)
    new  17:     ,dt as (select '00/01/2009' as dt from dual)
    DT
    Invalid Date
    SQL>

  • How to get AD reconciliation event data using SQL query.

    Hi All,
    I was trying to get all recon data for Target AD Recon from OIM db, but it seems that in OIM 11g we do not have recon data in tables: RCU, RCE, etc. We have to use "RECON_..." tables, my question is does any bady has sample query to fetch data from recon tables?
    best
    mp

    It should be a question of linking your AD user reconciliation table (beginning RA_) with the RECON_EVENTS table by RE_KEY.
    In my case I have OID user reconciliation (so my RA_ table will be different to yours) and can use something like:
    SELECT RECON_EVENTS.RE_STATUS, RA_OIDUSER5.* FROM RECON_EVENTS, RA_OIDUSER5 WHERE RECON_EVENTS.RE_KEY = RA_OIDUSER5.RE_KEY;
    Obviously it then depends on what information you want to filter on and retrieve.

  • Error in loading data using SQL loader

    I am getting a error like ‘SQL*Loader -350 syntax error of illegal combination of non-alphanumeric characters’ while loading a file using SQL loader in RHEL. The command used to run SQL*Loader is:
    Sqlldr userid=<username>/<password> control =data.ctl
    The control file, data.ctl is :
    LOAD data
    infile '/home/oraprod/data.txt'
    append  into table test
    empid terminated by ',',
    fname terminated by ',',
    lname terminated by ',',
    salary terminated by whitespace
    The data.txt file is:
    1,Kaushal,halani,5000
    2,Chetan,halani,1000
    I hope, my question is clear.
    Please revert with the reply to my query.
    Regards

    Replace ''{" by "(" in your control file
    LOAD data
    infile 'c:\data.txt'
    append  into table emp_t
    empid terminated by ',',
    fname terminated by ',',
    lname terminated by ',',
    salary terminated by whitespace
    C:\>sqlldr user/pwd@database control=c.ctl
    SQL*Loader: Release 10.2.0.3.0 - Production on Wed Nov 13 10:10:24 2013
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Commit point reached - logical record count 1
    Commit point reached - logical record count 2
    SQL> select * from emp_t;
         EMPID FNAME                LNAME                    SALARY
             1 Kaushal              halani                     5000
             2 Chetan               halani                     1000
    Best regards
    Mohamed Houri

  • ORA-01841 Error when value for date col is NULL in .dat (using SQL Loader)

    Hello Gurus,
    I have some data in .dat file which needs to be loaded into oracle table. I am using SQL * Loader to do the job. Although "NULLIF col_name =BLANKS" works for character datatype, but when value for date col is NULL then I get ORA-01841 error. I have to make NULL for all rows withour value for date column
    Early reply will be highly appreciated
    Farooq

    Hi,
    May be this problem is not with the NULLIF. The value for the date column is not in proper date format.
    create table:
    create table kk (empno number, ename varchar2(20), deptno number, hiredate date)
    Control file:
    LOAD DATA
    INFILE 'd:\kk\empdata.dat'
    insert into TABLE kk ( empno position (1:2) integer external,
    ename position(4:5) char NULLIF ename=BLANKS,
    deptno position (7:8) integer external NULLIF deptno=BLANKS,
    hiredate position (10:20) date NULLIF hiredate=BLANKS)
    data file:
    10 KK 01-jan-2005
    20 10
    SELECT * FROM KK;
    EMPNO ENAME DEPTNO HIREDATE
    10 KK 01-JAN-05
    20 10
    Verify the data file.
    Hope it will help

  • Loading leap year date using SQL*Loader

    Hello,
    I have a problem loading a date '29/02/2000' using SQL*Loader. This date is on a leap year. I'm getting an error message from SQL*Loader as 'ORA-01839: date not valid for month specified'. My colleague and I have tried using various date functions to convert the data into date, but no luck.
    I would appreciate any helps,
    Bruce

    Thanks for your help, I found the bug on my control file. I was using the RTRIM function to remove bad timestamp such as '29/02/2000 0:00:00'. So instead of using this statement:
    LOG_DATE DATE "DD/MM/RRRR" "RTRIM(:LOG_DATE,'0:00:00')"
    I was using the statement below with a space before the '0:00:00' string literal, with the intention to remove a space also:
    LOG_DATE DATE "DD/MM/RRRR" "RTRIM(:LOG_DATE,' 0:00:00')"
    Well, it turned out that if there was a space before the string literal, RTRIM function would trim the matching string plus any '0' characters from the right, including the '000' that belongs to '2000'. Thus, the error.
    Thanks again,
    Bruce

  • Copy hiearchical data using SQL only.

    Is there anyway to copy hiearchical data that use ID's without using a pl/sql loop procedure or a global temporary table?
    Example
    CREATE TABLE DUCK_TREE
    FIRST_NAME VARCHAR2(100 BYTE),
    LAST_NAME VARCHAR2(100 BYTE),
    FAMILY_ID NUMBER,
    PARENT_ID NUMBER
    INSERT INTO DUCK_TREE ( FIRST_NAME, LAST_NAME, FAMILY_ID, PARENT_ID ) VALUES (
    'Louie', 'Duck', 207, 203);
    INSERT INTO DUCK_TREE ( FIRST_NAME, LAST_NAME, FAMILY_ID, PARENT_ID ) VALUES (
    'Dewey', 'Duck', 206, 203);
    INSERT INTO DUCK_TREE ( FIRST_NAME, LAST_NAME, FAMILY_ID, PARENT_ID ) VALUES (
    'Huey', 'Duck', 205, 203);
    INSERT INTO DUCK_TREE ( FIRST_NAME, LAST_NAME, FAMILY_ID, PARENT_ID ) VALUES (
    'Donald', 'Duck', 204, 201);
    INSERT INTO DUCK_TREE ( FIRST_NAME, LAST_NAME, FAMILY_ID, PARENT_ID ) VALUES (
    'Thelma', 'Duck', 203, 201);
    INSERT INTO DUCK_TREE ( FIRST_NAME, LAST_NAME, FAMILY_ID, PARENT_ID ) VALUES (
    'Daphne', 'Duck', 202, 200);
    INSERT INTO DUCK_TREE ( FIRST_NAME, LAST_NAME, FAMILY_ID, PARENT_ID ) VALUES (
    'Quackmore', 'Duck', 201, 200);
    INSERT INTO DUCK_TREE ( FIRST_NAME, LAST_NAME, FAMILY_ID, PARENT_ID ) VALUES (
    'Grandma', 'Duck', 200, NULL);
    INSERT INTO DUCK_TREE ( FIRST_NAME, LAST_NAME, FAMILY_ID, PARENT_ID ) VALUES (
    'Hortense', 'McDuck', 103, 100);
    INSERT INTO DUCK_TREE ( FIRST_NAME, LAST_NAME, FAMILY_ID, PARENT_ID ) VALUES (
    'Scrooge', 'McDuck', 102, 100);
    INSERT INTO DUCK_TREE ( FIRST_NAME, LAST_NAME, FAMILY_ID, PARENT_ID ) VALUES (
    'Matilda', 'McDuck', 101, 100);
    INSERT INTO DUCK_TREE ( FIRST_NAME, LAST_NAME, FAMILY_ID, PARENT_ID ) VALUES (
    'Scotty', 'McDuck', 100, NULL);
    COMMIT;
    Now you would like to copy the hierachical data starting say at Grandma and all children?

    I can't really see a way to get away from iterative PL/SQL or the use of temporary tables (global or otherwise).
    The best solution I've managed to come up with so far is use at least 1 GTT to store a mapping of current FAMILY_IDs to new FAMILY_IDs, then use the map table to translate the old IDs to new IDs during the copy phase.
    DROP TABLE id_map;
    CREATE global TEMPORARY TABLE ID_MAP
        (   old_id NUMBER,
            new_id NUMBER
        ON COMMIT DELETE ROWS;
    DROP SEQUENCE duck_tree_seq;
    CREATE SEQUENCE duck_tree_seq INCREMENT BY 1
        START WITH 208;
    create or replace procedure ADD_DUCK_WITH_DESCENDENTS
          (fName varchar2, lName varchar2, pid number, RootID number) is
        new_id NUMBER;
    begin
        -- Create new Ancestor
        insert into duck_tree values (fname, lname, duck_tree_seq.nextval, pid)
        returning family_id into new_id;
        -- Add root mapping
        insert into id_map values (rootid, new_id);
        -- Map lineage
        INSERT INTO id_map
        WITH t AS
             SELECT d.*
               FROM duck_tree d
              WHERE level <> 1 -- exclude root ancestor
            CONNECT BY d.parent_id = PRIOR d.family_id
              START WITH d.first_name = 'Grandma'
         SELECT family_id, DUCK_TREE_SEQ.nextval newid FROM t;
        -- Copy descendents
        insert into duck_tree (
            first_name,
            last_name,
            family_id,
            parent_id)
        WITH t AS
            (SELECT d.*
               FROM duck_tree d
              WHERE level <> 1 -- exclude root ancestor
            CONNECT BY d.parent_id = PRIOR d.family_id
              START WITH d.first_name = 'Grandma'
         SELECT t.first_name
              , t.last_name
              , m1.NEW_ID
              , m2.NEW_ID
           FROM t
        JOIN id_map m1
             ON t.family_id = m1.old_id
        LEFT JOIN id_map m2
             ON t.parent_id = m2.old_id;
        -- Clear out the map table
        delete from id_map;
    end;
    call add_duck_with_descendents('Grandpa','Duck',null,200);
    /

  • How to get current navigation data using C#

    Hi,
    Please help me to get the current navigation data using c#.
    In detail, In my sharepoint 2013 site, if i navigate to the Site Actions -> Settings ->Navigation -> Current Naviation and add some link it should show on my web part.
    I am trying to create  a new web part and this web part should show the content of Current Navigation (under settings).
    Thanks in advance.

    Hi Lakshmanan,
    Thanks for your reply.
    I need more CSS customization so i am looking for C# code and i got the code. i am getting all the subsites but child nodes of subsites are showing zero even though the subsites having another subsites and pages.
    I have tried the below scranario,
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.navigation.spnavigation.quicklaunch.aspx
    Please help me on this. This is very urgent for me.
    Thanks a ton.

  • Filtering data using sql query

    I am pulling data from a database which is a log of events type data. It consists of entries at a certain time, entry text, and even has an entry type. One of those types is known as "open item." This entry has the potential to be present on multiple days over and over. The problem is I only want the "open item" entries to appear that occur on the most recent day of a date range that is input by the user, but also not excluding all other entries from all of the other days that are not "open item." The "is_open=0" is what is excluding the "open items" from all of the entries, but now there needs to be a way to include (ie. "is_open=1") the "open items" on the current day. My query is as follows:
    SELECT     b.log_title, a.log_id, MIN(a.shift_date) AS shift_date,a.shift_id,a.operator_position_descr,a.is_open,a.user_id, MAX(a.annotation_number) AS annotation_number,
                          a.entry_text, MIN(a.entry_time) AS entry_time,a.font_num
    FROM         log_entries AS a INNER JOIN
                          log_list AS b ON a.log_id = b.log_id
    WHERE ((entry_type_code NOT LIKE '%NLOG%'
                AND entry_type_code <> 'daily'
                AND entry_type_code <> 'shift act') or entry_type_code is null)
              AND (is_open = 0  AND is_standing_order = 0 AND is_rolled_forward is null) 
    GROUP BY b.log_title, a.log_id, a.user_id,a.shift_id,a.operator_position_descr,a.is_open, a.entry_text,a.font_num
    Order by entry_time

    Change you WHERE clause to something like this... (You didn't say what kind of DB you were using so I used SQL Server syntax)
    WHERE ((entry_type_code NOT LIKE '%NLOG%'
    AND entry_type_code IN ('daily', 'shift act')) OR entry_type_code is null)
    AND (is_open = 0 OR (is_open = 1 AND a.shift_date >= DateAdd(dd, DateDiff(dd, 0, GetDate()), 0)))
    AND is_standing_order = 0
    AND is_rolled_forward is null
    The biggest change is this... AND (is_open = 0 OR (is_open = 1 AND a.shift_date >= DateAdd(dd, DateDiff(dd, 0, GetDate()), 0))).
    It allows is_open = 1 if the shift_date is =&gt; midnight of the of the current day.
    HTH,
    Jason

Maybe you are looking for