Monday, March 19, 2012

Date information

I am trying to create an sp that will be put into a report that allows me to
pull information based on the last day to day year. E.g. today is 4/20/2005
and I would like to be able to pull info between 4/20/2004 and today, but I
want this to be dynamic so that it will pull the data tomorrow for 4/21/2004
to 4/21/2005where your_datetime_col between @.your_datetime_para and
dateadd(y,1,@.your_datetime_para)
-oj
"DBA" <DBA@.discussions.microsoft.com> wrote in message
news:50A09C7A-410D-4768-BC74-23D8D22516A0@.microsoft.com...
>I am trying to create an sp that will be put into a report that allows me
>to
> pull information based on the last day to day year. E.g. today is
> 4/20/2005
> and I would like to be able to pull info between 4/20/2004 and today, but
> I
> want this to be dynamic so that it will pull the data tomorrow for
> 4/21/2004
> to 4/21/2005|||SELECT
*
FROM <YourTable> WHERE <DateColumn> BETWEEN
DATEADD(YEAR, -1, GETDATE())
AND
GETDATE()
Hope it helps

No comments:

Post a Comment