• obarahmeh (7/9/2008)


    Thanks for ur Comments and reply,

    First: I have two columns; one for the 'DayTransDate' like (2008/08/09) which is stored in the Data base as a Decimal= 20080709, and the other is for 'DayTransTime' like (12:08:44) which is stored in the Data base as a Decimal= 120844.

    Dates should be stored in the database as datetime data type.

    You are going to have to convert the decimal date and time into a valid datetime column for the comparison. I think this might do it:

    SELECT columns

    FROM table

    WHERE convert(datetime, cast(DayTransDate AS char(8))

    + ' ' + STUFF(STUFF(CAST(DayTransTime AS char(6), 5, 0, ':'), 3, 0, ':'))

    > DATEADD(minute, -30, getdate());

    As for sending the rows from the query, I don't know what you are using to send the mail. In SQL Server 2005 - you could use sp_send_dbmail to send the above query.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs