How to determine if first date in multi record dataset is between certain date range.

Post Author: wal
CA Forum: Formula
I am trying to determine how many patients enrolled in our database from 1/1/2000 to 12/31/2003. The "ltvisit" table has a field called "visit_date" which is the field I am working with to determine. How do I code in crystal reports to find out if the FIRST visit_date record (FIRST VISIT) was between 1/1/2000 and 12/31/2003. Thanks.

Post Author: yangster
CA Forum: Formula
are you creating this in a command or you just bringing in the information from a single table or whatwhat you need to do is do a simple queary to pull in the first record from the patientonce you have that date then you then can do a simple in statement between your 2 dates

Similar Messages

  • How to get the first and the last record of every month within a time range in sql

    I am trying to get the first record and the last record of each and every month in a given date range using sql. I have a sample code
    where i have just selected everything within the date range now i have to extract the first and the last records of each and every month.
    SELECT PurOrderNum,
    OrderDate
    FROM Purchasing.PurOrder
    WHERE OrderDate >= '2013-02-28'
    AND OrderDate <= '2014-12-29'

    SELECT PurOrderNum,
    OrderDate
    FROM
    SELECT PurOrderNum,
    OrderDate,
    MAX(OrderDate) OVER (PARTITION BY DATEDIFF(mm,0,OrderDate)) AS MaxDate,
    MIN(OrderDate) OVER (PARTITION BY DATEDIFF(mm,0,OrderDate)) AS MinDate
    FROM Purchasing.PurOrder
    WHERE OrderDate >= '2013-02-28'
    AND OrderDate <= '2014-12-29'
    )t
    WHERE OrderDate = MaxDate
    OR OrderDate = MinDate
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Updating data from multi record blocks and database

    Hi
    when the user presses a button, records are retrieved from the database and put into multi record item. User can change the data that is retrieved from the database by pushing update button.I tried this code inside update button but it isnt working...
    Begin
    go_block('PRODUCTS');
    first_record;
    LOOP
    update products
    set PRODUCTS.PRODUCT_ID=:PRODUCTS.PRODUCT_ID
    where PRODUCTS.PRODUCT_ID=:CUSTOMER.CUSTOMER_ID;
    exit when :system.last_record = 'TRUE';
    next_record;
    END LOOP;
    forms_ddl('commit');
    clear_block(no_validate);
    End;

    Hi
    when the user presses a button, records are retrieved
    from the database and put into multi record item.
    User can change the data that is retrieved from the
    database by pushing update button.I tried this code
    inside update button but it isnt working...
    Begin
    go_block('PRODUCTS');
    first_record;
    LOOP
    update products
    set PRODUCTS.PRODUCT_ID=:PRODUCTS.PRODUCT_ID
    where PRODUCTS.PRODUCT_ID=:CUSTOMER.CUSTOMER_ID;
    exit when :system.last_record = 'TRUE';
    next_record;
    END LOOP;
    forms_ddl('commit');
    clear_block(no_validate);
    End;Are you getting an error?, what is it that it isn't working?
    One thing you need to understand about the basics of a block:
    If it is a block based on a database table you do not need an external INSERT/UPDATE/DELETE statements from a button or anything.
    Users can change the data retrieved from the database and just press save (which includes only commit_form built in).

  • How can i build a portlet with multi-record fields

    Hi
    I am building an application and some of my forms need to capture multi-records fields,for example like Developer Forms does with Grids
    Can anybody send me an example to do this?.
    Thanks

    This is what I did in our application.
    1. Created a Master Detail Form (Custom Layout and not tabular)
    and in the master block selected only one field.
    2. In the HTML layout for master removed the reference for
    that field(so that nothing will appear in the master block
    of the form).
    3. Before the update (in the Pl/SQL event handler selected the 'Save' event and written the following code to avoid updating master block).
    p_session.set_value(p_block_name => 'MASTER_BLOCK',
    p_attribute_name => 'MASTER_ACTION',
    p_value => 'None');
    doSave;
    For eg, let's say
    Master is from 'Dept' table and Detail is from 'Emp' table(with join condition Dept.dept_id = Emp.dept_id). In the master remove everything except dept_id field and in the HTML layout for master remove the reference of the dept_id field(you cannot remove this field physically from the master layout). Now the form will look like multirow form rather than master detail form but only problem with this workaround is 'Detail Action' will be present in the detail block.
    I hope this will help you.
    Thanks
    -Krishnamurthy

  • Date difference function that returns minutes between two dates and excludes weekends and holidays

    Is there a way to get this to work as a function? 
    Currently returns error "Select statements included within a function cannot return data to a client"
    CREATE FUNCTION [dbo].[WorkDays](@DateFrom datetime,@DateTo datetime)
    RETURNS int
    AS
    BEGIN
    --Working time
    DECLARE @WTFrom TIME = '8:00AM';
    DECLARE @WTTo TIME = '5:00PM';
    DECLARE @minCount BIGINT
    --Date ranges
    IF (DATEDIFF(HOUR, @DateFrom, @DateTo) > 12)
    BEGIN
    WITH CTE AS
    SELECT @DateFrom AS DateVal
    UNION ALL
    SELECT DATEADD(HOUR, 1, DateVal)
    FROM CTE
    WHERE DateVal < DATEADD(HOUR, -1,@DateTo)
    SELECT DATEDIFF(minute, MIN(CTE.DateVal), MAX(CTE.DateVal))
    FROM CTE
    WHERE (CAST(CTE.DateVal AS time) > @WTFrom AND CAST(CTE.DateVal AS time) < @WTTo) AND DATEPART(dw, CTE.DateVal) NOT IN (1, 7) AND NOT EXISTS (SELECT * FROM Holiday AS H WHERE H.holiday = CTE.DateVal)
    OPTION (MAXRECURSION 0);
    END;
    ELSE
    BEGIN
    WITH CTE AS
    SELECT @DateFrom AS DateVal
    UNION ALL
    SELECT DATEADD(MINUTE, 1, DateVal)
    FROM CTE
    WHERE DateVal < DATEADD(MINUTE, -1,@DateTo)
    SELECT DATEDIFF(minute, MIN(CTE.DateVal), MAX(CTE.DateVal))
    FROM CTE
    WHERE (CAST(CTE.DateVal AS time) > @WTFrom AND CAST(CTE.DateVal AS time) < @WTTo) AND DATEPART(dw, CTE.DateVal) NOT IN (1, 7) AND NOT EXISTS (SELECT * FROM Holiday AS H WHERE H.holiday = CTE.DateVal)
    OPTION (MAXRECURSION 0);
    END;
    END
    Thanks for your help.

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules (you do not). Temporal
    data should use ISO-8601 formats (you do not!). Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. 
    We hate functions in SQL. This is a declarative language and you are using it like 1950's FORTRAN. We hate local variables (more FORTRAN!)
     The name of a function has to be either a known, common name, like “sine”, “cosine” etc. Or it is “<verb>_<object>”; you think a noun is a verb! Do you really need BIGINT? Why did you invite garbage data with it? Why do you think that SQL
    uses AM/PM? Have you never seen the TIME data type? 
    Think about “date_val” as a data element name. A date is a unit of temporal measurement on a calendar scale. This would be a “<something>_date” in a valid schema. 
    >> Is there a way to get this to work as a function? <<
    Probably, but why do it wrong?
    Build a calendar table with one column for the calendar data and other columns to show whatever your business needs in the way of temporal information. Do not try to calculate holidays in SQL -- Easter alone requires too much math.
    The julian_business_nbr is how SQL people do this. Here is the skeleton. 
    CREATE TABLE Calendar
    (cal_date DATE NOT NULL PRIMARY KEY, 
     julian_business_nbr INTEGER NOT NULL, 
    Here is how it works:
    INSERT INTO Calendar 
    VALUES ('2007-04-05', 42), 
     ('2007-04-06', 43), -- Good Friday 
     ('2007-04-07', 43), 
     ('2007-04-08', 43), -- Easter Sunday 
     ('2007-04-09', 44), 
     ('2007-04-10', 45); --Tuesday
    To compute the business days from Thursday of this sample week to next Tuesday:
    SELECT (C2.julian_business_nbr - C1.julian_business_nbr)
      FROM Calendar AS C1, Calendar AS C2
     WHERE C1.cal_date = '2007-04-05',
       AND C2.cal_date = '2007-04-10'; 
    See how simple it can be when you stop trying to write FORTRAN and think in sets? 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to Determine the first day of the current Fiscal Year

    I am a SQL Server developer who is trying to to learn Oracle SQL. I am trying to write a query that will 1) determine the month number and if the number is 10, 11, or 12, will return '01-Oct-' of the current Calendar year. If the month number is between 1 and 9, it returns '01- Oct-' of the last Calendar year (YYYY = current Calendar year minus 1 year).
    I was playing with the EXTRACT function to get the year and month, but was unable to formulate the '1-Oct-YYYY' where YYYY is the current or previous calendar year, depending on whether the SYSDATE falls before or after 1-October.
    Could anyone point me to an example of how to do this in Oracle?

    We can use "add_months" B-)
    select column_value,
    extract(year from add_months(column_value,-9)) as y,
    add_months(trunc(add_months(column_value,-9),'yyyy'),9) as oct
    from table(sys.odciDateList(
    date '2009-01-01',date '2009-09-01',
    date '2009-10-01',date '2009-12-01'));
    COLUMN_V     Y  OCT
    09-01-01  2008  08-10-01
    09-09-01  2008  08-10-01
    09-10-01  2009  09-10-01
    09-12-01  2009  09-10-01

  • Find the first and last day of week giving a certain date

    Hi,
    i have an application in wich the user puts a date, say today 2010-08-10 and i have to calculate first and last day of that week, in this case 2010-08-09 and 2010-08-15. How can i do this?
    Many thanks in advance,
    Nuno Almeida

    nfalmeida wrote:
    i have an application in wich the user puts a date, say today 2010-08-10 and i have to calculate first and last day of that week, in this case 2010-08-09 and 2010-08-15. How can i do this?First step is being sure that you know what a 'week' is.
    For example does it really start on monday? And will it always start on monday?
    And what day does the 'week' end on for 2010-12-29? In some businesses it will end on 2010-12-31 (friday)

  • Return data from all columns apart from a certain data type.

    Bit stuck on something, hope somebody here can help:
    I want to do a 'select * from ' a table, to return all columns except ones of a certain datatype. ie. I want to return data from all columns, excluding columns of datatype 'SDO_GEOMETRY'.
    This gives me the list of columns:
    SELECT COLUMN_NAME
    FROM   USER_TAB_COLUMNS
    WHERE TABLE_NAME = 'ORDER_ITEM'
    AND   DATA_TYPE <> 'SDO_GEOMETRY'; But I can't seem to take it any further...
    Now if I knew the columns beforehand, then of course I could just list them, excluding the geometry column, but this is to be used for a plug-in for MS Word, where a user can pick database columns to dynamically fill a report from - but I don't want the geometry columns as these can't be handled in this way.

    Hi Reggie,
    > connects to the database and presents a list of tables
    My guess is that this macro is written so it selects from all_tab_cols.
    Change that plugin and let it select from a view like the one above. That way, the users won't be able to see/pick anything that you are not able/willing to present for them.
    Edit:
    You could even tease your users, and let them see the columns, but not being able to pick them.
    create or replace view available_tab_columns
    as
       select decode(pickable.data_type, null, 0, 1) pickable
             ,atc.* -- narrow down yourself
         from all_tab_cols atc  -- or maybe user_tab_cols
             ,(select 'CHAR' data_type from dual union all
               select 'DATE' from dual union all
            select 'NUMBER' from dual
               -- complete positive list, yourself
              ) pickable
        where atc.data_type = pickable.data_type(+);Regards
    Peter
    Message was edited by:
    Peter Gjelstrup

  • Sum up between certain dates-tsql query

    Hi,
    We have a following scenario,
    DATE
    MONTH start
    MONTH end
    IS BUSINESS DAY
    2014-02-23
    2014-02-01
    2014-02-28
    0
    2014-02-24
    2014-02-01
    2014-02-28
    1
    2014-02-28
    2014-02-01
    2014-02-28
    1
    For example, if date 2014-02023 is chosen, then we need to sum total business days for the whole month. Table is similar as above,
    select * from  A where date = '2014-02-23'. If we choose this day, then need to sum for column "is business day" for all rows with month end of '2014-02-28, month start of '2014-02-01' .
    Is ther any easier way to calculate this? Appreciate for your feedback.

    If you have a date (or datetime) in a variable named @TestDate, then this should give you the result you want.
    Select Sum([IS BUSINESS DAY]) As BusinessDays
    From YourTable
    Where [Month Start] = Cast(Convert(char(6), @TestDate, 112) + '01' As Date)
    Tom

  • Lost all mail between certain dates

    I've lost all my mail between September 30 and January 14 in the in box and the sent mail.
    This is across the 3 accounts I have set up.
    The trash box holds nothing prior to January 14th.
    All very confusing, and even more annoying. Any of you smart people got any idea what could be causing this, or more importantly how I could retrieve the files.
    Many Thanks

    Let's force an overall reindexing via the removal of the Envelope Index since you say it is spread across all accounts. Note the special instructions when forcing the reindexing of IMAP or Exchange accounts in the following:
    http://docs.info.apple.com/article.html?path=Mail/3.0/en/14019.html
    This will force the reindexing of all the POP mailboxes and any On My Mac mailboxes. With regard to the IMAP account, the practical result of this action of removing the account folder, is that with the IMAP account still set up in the Preferences, Mail will connect to the IMAP server and create a new account folder, and while doing so will index the messages in the mailbox folders of the IMAP account on the server. Not removing the IMAP account folders when removing the Envelope Index file may lead to strange results -- have you by any chance ever forced a reindexing by removing the Envelope Index? This could have happened if you ever used a suggestion to remove all files except folders to cure a problem some people encountered when upgrading to 10.5.6 from 10.4.11 (was not the preferred solution however.
    May I assume that all standard mailboxes related to the IMAP account are stored on the server, as would be normal?
    Keep me posted.
    Ernie

  • What is the Difference Between Sys Date and Effective Date ??

    Hi Gurus,
    Can any one pls let me know What is the Difference Between Sys Date and Effective Date ??
    with regards
    User600722

    EFFECTIVE DATE usually refers to a date-tracked record (although not exclusively).
    Date-tracked records in Oracle HR have an EFFECTIVE START DATE and an EFFECTIVE END DATE. The record is 'EFFECTIVE' between these dates. In reports, you often use SYSDATE to compare to these two dates to find the CURRENT effective record, e.g. SYSDATE BETWEEN EFFECTIVE START DATE AND EFFECTIVE END DATE.
    When you make changes to a HR record, you can choose between DATE TRACKING options, such as CORRECT or UPDATE (there are others too). CORRECT will overwrite the record and replace the data with your changes. This is normally used when you need to correct something that is wrong. UPDATE will create a new version of the record from the EFFECTIVE START DATE you choose. It will also set the EFFECTIVE END DATE of the previous record to the day before your new record's EFFECTIVE START DATE. That enables a history of records to be maintained so you can see what your data looked like at ay one point in time.
    Regards
    Tim
    Edited by: TimW on Sep 23, 2008 2:37 PM

  • How can I create a loop in a multi-record block (on the background)

    I have a multi-record block.
    In one item I change a value.
    Upon this change, in the when-validate-item I would like to
    change other records in the same block.
    I planned to loop the block with go_record and to do my things
    in each record. Unfortunately the go_record built-in is
    restricted and cannot be used in a wvi-trigger.
    Another approach can be to update the records in the database
    and to perform an execute_query after this change. Also this
    procedure cannot be used in a wvi.
    How can I easily loop in a multi-record block???

    You can try to put loop with go_record in KEY-NEXT-ITEM on that
    field.
    Or if you change something and then press KEY-COMMIT you can
    update another records in database and after commit do again
    execute_query. Something like :
    on KEY-COMMIT:
    update_another_records;
    commit_form;
    execute_query;

  • How to calculate days between 2 dates excluding public holidays over SAP ?

    Hi
    Have a universe over SAP data. Trying to calculate days between 2 dates. SAP holds Public Holiday data in various tables e.g  Thol and data is updated via scal. Using my univeres as a source I want to run  reports for different countries so need to have various bank holidays not just UK. In SAP function modules handle this. Has anyone designed a solution to cater for this situation in a universe ?
    Thanks in advance
    M

    Hi,
    I assume you mean SAP R/3 (ECC) when you write SAP and SAP BW.
    Are you using BW? If so, I would load the data into SAP BW, create a query using customer exit variables and build your universe on top of that...
    -J

  • Write multi-records

    Hi Experts,
    I found very good how-to guide in SDN to read multi records with cobol copybook.
    And I would like to write multi records txt file? Every line has different length but fixed. I can have repetitif line like contact because vendor can have several contact but all contacts have the same fixed length.
    Exemple Vendor
    Vendor:<Name><Type>...
    Address:<Address>...
    Contact:<Fix Telephone>..
    Contact:<Moble Telephone>...
    Vendor:<Name><Type>...
    Address:<Address>...
    Contact:<Fix Telephone>..
    Vendor:<Name><Type>...
    Address:<Address>...
    Contact:<Fix Telephone>..
    Contact:<Moble Telephone>...
    Thanxs,
    Nl
    Edited by: User NL on Sep 10, 2009 4:51 PM

    Reading yes, writing no.
    There are workarounds, e.g. write one file with all header rows, another with all detail rows and both files have the header plus a number in the first two fields, e.g.
    HEADER
    ORDER;1;data
    00001;1;abc
    00002;1;def
    00003;1;ghi
    DETAIL
    ORDER;2;LINE;data
    00001;2;0001;xyz
    00001;2;0002;sge
    00001;2;0003;dff
    00002;2;0001;rfew
    When you then take both files, merge them together and sort them you get them interleaved
    00001;1;abc
    00001;2;0001;xyz
    00001;2;0002;sge
    00001;2;0003;dff
    00002;1;def
    00002;2;0001;rfew
    00003;1;ghi
    This is just one approach, other work similar. The only multi-record format DS can write out of the box is XML.

  • Payroll operation: comparison with a certain date

    Hello, everybody,
    I am trying to compare the employee's date of seniority from IT0041 with a certain date (ex: first of september 2001) so as to calculate my seniority bonus (because the calculation rule is not the same for the employees who have the seniority date before or after entrering the first of september 2001). I have tried to use the payroll function NUM=F... but this gives me only the number of years, or months till the current payroll period, and not the month and year from infotype 0041 and I do not know how to compare the given date and the date coming from the infotype.
    please help me
    thanks in advance
    natachalek

    You can compare the employee's date of seniority from IT0041 with a certain date in a customer operation %xyz (model E7) created in tcode PE04.
    The dates from IT0041 are available in an internal table DATUMSANGABE. Develop ABAP code as follows:
      FORM op%xyz.
        DATA: date TYPE d VALUE '20010901'.
        READ TABLE datumsangabe WITH KEY typ = '01'.
        IF datumsangabe-wert LT date.
          vargt = 'X'.
        ELSE.
          vargt = '*'.
        ENDIF.
        PERFORM fillvargt.
      ENDFORM.
    In the payroll schema where the seniority bonus is performed, create decision operation %xyz. For the variable key 'X' process the bonus WT for employees hired before 1st Sep 2001 and for others use the branch with variable key '*'.
    Regards,
    Renata

Maybe you are looking for

  • HELP! i need to undo syncing of 2 Blackberry devices!!!!!!!!

    I had an OLD black berry (think the very first version) that i was using as a temporary phone while Bell sorted somethings out. Needless to say i got a Storm 2 9550 to replace that, however did not do a transfer sync right at once. So both phones end

  • Password keeps getting reset.

    Hi there. I've had my password been reset about 20 times in the last few months, not by me. I keep getting emails saying that my password has been reset without my consent. I've changed the password back every single time, each time making it increas

  • E Mac too old to watch Video streaming from web?

    Hi good folks of Apple world. I am having an 'issue' with my eMac 1.25 GHz PowerPC G4 with 1 GB DDR SRAM. Mac OS X Version 10.4.11. Apart from a problem with the logic board (fixed under extended warranty) this has been an amazingly reliable machine.

  • Gzip with servlet

    Hi, I am facing a problem with servlet which compresses the MS Excel files in gzip format, when i try opening the Template.gz file using winzip or gzip.exe,it throws me an error as either " invalid zip file" or " archive directory not valid" Can some

  • Why is there missing EXIF metadata after merging aperture libraries?

    I had an old library and a new library. All metadata and files were fine in the respective libraries. After importing one into the other, I am missing all EXIF metadata like Camera, Lens, ISO, Aperture, Focal Length. Anyone experience this problem or