How to get last 5 days back date

  • Hi all

    How to get last 5 days back date

  • Not sure I understand what you want.

    If you want the date of 5 days ago, this will get it. If you want something else, please explain further what it is that you want.

    DECLARE @CurrentDateWithoutTime DATETIME

    SET @CurrentDateWithoutTime = DATEADD(dd,DATEDIFF(dd,0,getdate()),0)

    SELECT DATEADD(dd,-5,@CurrentDateWithoutTime) AS FiveDaysAgo

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • sad thing is I know I will never get the last 5 days back................:-)

    ---------------------------------------------------------------------

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

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