Help with DatePart or Dataadd view script?

  • david.ostrander (1/31/2012)


    You have helped me out so much Thank you... I can see how it all works now.

    Thats what the community is for right ? 🙂

    [font="Times New Roman"]There's no kill switch on awesome![/font]
  • Hi there again. I hate to bug you but I was hoping to pick your brain again on this topic.

    We have an SSIS job that runs and pull data into this staging table which people connect too within excel.

    On Fridays at 4:00 PM that data run is kept in the same table and not deleted.

    What I'm looking to do is run the view but no include this time frame 2012-01-27 16:00:00 it is another column names PIT

    ALTER VIEW [dbo].[BackLogLabor13Wks]

    AS

    SELECT *

    FROM dbo.BacklogLabor

    WHERE ([Schedule Week] >= CONVERT(CHAR(10), DATEADD(DD, - 7, GETDATE()), 121)) AND ([Schedule Week] < CONVERT(CHAR(10), DATEADD(DD, 91, GETDATE()), 121))

    Thought to that?

    thanks

    D-

  • so you have another column called PIT which holds datetime values?

    [font="Times New Roman"]There's no kill switch on awesome![/font]
  • Yes that PIT time is generated when the SSIS job runs.

  • i suppose you could add this to the where clause

    AND PIT != CONVERT(CHAR(10),GETDATE(),121) + '16:00:00'

    This will check the PIT column and exclude the current day at 16:00. Remember though that if the job doesn't populate the column with that exact time (i.e adds some milliseconds) then this condition won't pass.

    [font="Times New Roman"]There's no kill switch on awesome![/font]

Viewing 5 posts - 16 through 19 (of 19 total)

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