?
Solved

check date plus 90 days

Posted on 2007-11-26
2
Medium Priority
?
1,448 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

770 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