[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

check date plus 90 days

Posted on 2007-11-26
2
Medium Priority
?
1,475 Views
Last Modified: 2008-02-01
I have a query where I need to check if the date stored in the database is still active.  The formula to determine if the date is still active is if the if the Contract_End_c field is not past todays date plus 90 days.

The date stored in the database is in the format: mm/dd/yyyy

This is what I was trying:

Select a.AccountNumber, a.Contract_End__c from Account a WHERE a.AccountNumber = '123456' AND a.Contract_End_c <= DATEADD(dd, 90, getdate())

Thanks for any help.
0
Comment
Question by:-Dman100-
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
JR2003 earned 1000 total points
ID: 20351495
The date is stored in a text column?
You will need to convert it to a date

AND Cast(Right(Contract_End_c,4) + '-' + Left(Contract_End_c, 2) + '-' + SUBSTRING(Contract_End_c,4 , 2) as datetime)  <= DATEADD(dd, 90, getdate())

0
 
LVL 18

Assisted Solution

by:Yveau
Yveau earned 1000 total points
ID: 20351743
... or (as it is stored as a string):

Hope this helps ...

Select  a.AccountNumber
,       a.Contract_End__c 
from    Account a 
WHERE   a.AccountNumber = '123456' 
AND     convert(datetime, a.Contract_End_c, 101) <= DATEADD(dd, 90, getdate())

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question