Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Constraint Violating Yak Guru

420 Posts

Posted - 02/24/2013 :  22:17:28  Show Profile  Reply with Quote
i would like to get yesterday's date

YesterdayDate= DATEADD(Day,-1,Cast(getdate() as Date))

hit this error:Type Date is not a defined system type.

Starting Member

21 Posts

Posted - 02/24/2013 :  22:41:28  Show Profile  Reply with Quote
Hope this helps

SELECT DATEADD(day,-1, GETDATE() ) AS "YesterdayDate"
Go to Top of Page

Constraint Violating Yak Guru

420 Posts

Posted - 02/24/2013 :  23:01:33  Show Profile  Reply with Quote
is in where condition
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 02/24/2013 :  23:18:43  Show Profile  Reply with Quote
date works only from 2008 onwards. you dont need the casting there. just do

WHERE datefield >= DATEADD(dd,DATEDIFF(dd,0,GETDATE()),-1)
AND datefield < DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0)


SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000