Results 1 to 7 of 7

Thread: Displaying only the last 5 day's records.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Brunei
    Posts
    100

    Displaying only the last 5 day's records.

    Hi everyone,

    I use the data grid to display the records from a sybase database. The problem is the user has 1000's of records to display, which takes a lot of time.

    They want to see only the last few day's transactions.

    How can I set up the Adodc control to display only the last 10 reocrds or only last few days records?

    How can I set up the record source of the Adodc control, some thing like this,

    Select * from tblInvoice where Trx_date between today and 5 days before today.

    or

    Select only the last 10 records from tblInvoice.


    Any help is greatly appreciated.

    Thank you.

    sincerely,
    rathi

  2. #2
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    FL
    Posts
    258
    DO you have anything (Field) in the Table to indicate the date, like a time stamp field or date added field. If so you can make the RecordSource of the ADODC to something like...

    SELECT * FROM T_OBJECT WHERE TimeStamp > '2000/11/08'

    If not then you can use the SQL TOP keyword...

    SELECT TOP 10 * FROM T_OBJECT

    Or you can return a Percentage of the records...

    SELECT TOP 10 PERCENT * FROM T_OBJECT

  3. #3
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Or use SQL's between method!

    Data1.RecordSource = "SELECT table1.* FROM table1 WHERE table1.date BETWEEN date And date2"

    Or something similar!

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Brunei
    Posts
    100

    Thank you.

    HI,

    Thanks for your reply.

    I used the follwoing query,

    Select Top 10 Trx_Date, Receipt_No, Payer_Code, Trx_Amount from v_receipt_hdr
    Where Company_id = 3708
    ORDER BY Trx_date desc


    Now, I can display the latest 10 records.

    sincerely,

    rathi

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Brunei
    Posts
    100

    More details, please

    Hi,

    I can use the

    Select * from tblInvoice where trx_date between date1 and date2.


    Here date1 is today, date 2 is 5 days before today.

    How can calculate the date 2? Is there any function to do this?

    Pls. reply if you have any idea.

    sincerely,

    rathi

  6. #6
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    To do it simply you could get the user to input it!

    If you want todays date just type Date in the sql!

    Date2 just type Date - 5!

    I.e msgbox Date - 5

    Dim date2 as string
    date2 = Date - 5

    Select * from tblInvoice where trx_date between Date and date2.

  7. #7
    Addicted Member
    Join Date
    Nov 2000
    Location
    North East (UK)
    Posts
    204
    Hi all,

    this is the code I normally use to return the last so many days of Information, hope its of use to someone.

    Colin

    select * from MyLeave where MyDate > getdate() -14

    It uses the current system time to return all records input within the last 14 days. Usefull when you want to return more than a fixed number of records.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width