create procedure date

  • hi

    SP with input parameters start_dte, end_dte, all

    1.If end_dte is not specified, then need to take today’s date_time.

    2.If start_dte is not specified, then need to take today’s date_time – 7 (to get data for last 7 days)

    3.‘All’ Boolean parameter, if yes, then need to send all data available in the system from beginning till date.

    thanxs

  • Hi

    CREATE procedure_name @start_dte datetime = NULL, @end_dte datetime = NULL, @all varchar(1) bit = 0

    1. IF @end_dte IS NULL SET @end_dte = GETDATE()

    2. IF @start_dte IS NULL SET @start_dte = GETDATE() - 7

    3. IF @all = 1

        BEGIN

        SET @start_dte = '19000101'

        SET @end_date = GETDATE()

        END

    Explain situation and requirements in more detail if this doesn't help. May need some tweaking depending on whether you are using or not using time portion in columns compared with start date / end date.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply