How can I use datediff function so that it returns me date with less
then or equal to 13 months from today?
thanksInstead of DATEDIFF, use DATEADD function like:
DATEADD( m, -13, CURRENT_TIMESTAMP )
Anith
Showing posts with label datediff. Show all posts
Showing posts with label datediff. Show all posts
Monday, March 19, 2012
Sunday, March 11, 2012
Date function
Is it possible to retrive the number of days between two dates.
I'm aware of the DateDiff function but I can't figure out how to calculate the number days between two columns containing dates in a table.
All help is welcome
Regrads OISselect datediff (dd,col1,col2) from your table|||declare @.fd1 datetime, @.fd2 datetime
set @.fd1 = '20040513'
set @.fd2 = getdate()
select datediff(d, @.fd1, @.fd2)|||It works perfect :)
Thanks alot both of you|||Try to use BOL next time. Your example described in detail
I'm aware of the DateDiff function but I can't figure out how to calculate the number days between two columns containing dates in a table.
All help is welcome
Regrads OISselect datediff (dd,col1,col2) from your table|||declare @.fd1 datetime, @.fd2 datetime
set @.fd1 = '20040513'
set @.fd2 = getdate()
select datediff(d, @.fd1, @.fd2)|||It works perfect :)
Thanks alot both of you|||Try to use BOL next time. Your example described in detail
Friday, February 24, 2012
Date enquiry
How would I do a datediff between the date within a record in the dataset
and an entered in parameter?
The following works in giving me the difference from the record to now...
but I need to change the now to the @.to parameter.
DATEDIFF([day], view.DATE, GETDATE()) AS noofdays
ThanksYou can pass the date parameter to the SP and then do the
DateDiff.
>--Original Message--
>How would I do a datediff between the date within a
record in the dataset
>and an entered in parameter?
>
>The following works in giving me the difference from the
record to now...
>but I need to change the now to the @.to parameter.
>
>DATEDIFF([day], view.DATE, GETDATE()) AS noofdays
>Thanks
>
>.
>|||DATEDIFF([day], view.DATE, CAST(@.to, datetime)) AS noofdays
"AshVsAOD" <.> wrote in message
news:%23UmDBoKkEHA.3896@.TK2MSFTNGP15.phx.gbl...
> How would I do a datediff between the date within a record in the dataset
> and an entered in parameter?
>
> The following works in giving me the difference from the record to now...
> but I need to change the now to the @.to parameter.
>
> DATEDIFF([day], view.DATE, GETDATE()) AS noofdays
> Thanks
>|||Thanks!
"D Lee" <dle@.d.com> wrote in message
news:e5jYN0nlEHA.3912@.TK2MSFTNGP12.phx.gbl...
> DATEDIFF([day], view.DATE, CAST(@.to, datetime)) AS noofdays
> "AshVsAOD" <.> wrote in message
> news:%23UmDBoKkEHA.3896@.TK2MSFTNGP15.phx.gbl...
> > How would I do a datediff between the date within a record in the
dataset
> > and an entered in parameter?
> >
> >
> > The following works in giving me the difference from the record to
now...
> > but I need to change the now to the @.to parameter.
> >
> >
> > DATEDIFF([day], view.DATE, GETDATE()) AS noofdays
> >
> > Thanks
> >
> >
>
and an entered in parameter?
The following works in giving me the difference from the record to now...
but I need to change the now to the @.to parameter.
DATEDIFF([day], view.DATE, GETDATE()) AS noofdays
ThanksYou can pass the date parameter to the SP and then do the
DateDiff.
>--Original Message--
>How would I do a datediff between the date within a
record in the dataset
>and an entered in parameter?
>
>The following works in giving me the difference from the
record to now...
>but I need to change the now to the @.to parameter.
>
>DATEDIFF([day], view.DATE, GETDATE()) AS noofdays
>Thanks
>
>.
>|||DATEDIFF([day], view.DATE, CAST(@.to, datetime)) AS noofdays
"AshVsAOD" <.> wrote in message
news:%23UmDBoKkEHA.3896@.TK2MSFTNGP15.phx.gbl...
> How would I do a datediff between the date within a record in the dataset
> and an entered in parameter?
>
> The following works in giving me the difference from the record to now...
> but I need to change the now to the @.to parameter.
>
> DATEDIFF([day], view.DATE, GETDATE()) AS noofdays
> Thanks
>|||Thanks!
"D Lee" <dle@.d.com> wrote in message
news:e5jYN0nlEHA.3912@.TK2MSFTNGP12.phx.gbl...
> DATEDIFF([day], view.DATE, CAST(@.to, datetime)) AS noofdays
> "AshVsAOD" <.> wrote in message
> news:%23UmDBoKkEHA.3896@.TK2MSFTNGP15.phx.gbl...
> > How would I do a datediff between the date within a record in the
dataset
> > and an entered in parameter?
> >
> >
> > The following works in giving me the difference from the record to
now...
> > but I need to change the now to the @.to parameter.
> >
> >
> > DATEDIFF([day], view.DATE, GETDATE()) AS noofdays
> >
> > Thanks
> >
> >
>
Subscribe to:
Posts (Atom)