Please start any new threads on our new site at http://forums.sqlteam.com. 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!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 GETDATE() in tsql look up
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

taunt
Posting Yak Master

128 Posts

Posted - 06/11/2013 :  17:31:45  Show Profile  Reply with Quote
Hello I'm running this:

INSERT INTO itemsNRSH
(columns...)
SELECT columns...
FROM items
WHERE (ReleaseDate like 'GETDATE()') AND (StockQty > 0)

The releasedate column is formatted like so 2013-06-11 00:00:00.000. How can I get it to look at todays date "GETDATE()" when it runs? Right now when it runs it retrieves (0 row(s) affected).

Thanks

Edited by - taunt on 06/11/2013 17:32:19

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

USA
7020 Posts

Posted - 06/11/2013 :  17:45:12  Show Profile  Reply with Quote

where
	-- ReleaseDate GE today at 00:00:00.000
	ReleaseDate >= dateadd(dd,datediff(dd,0,GETDATE()),0)	and
	-- ReleaseDate before tomorrow at 00:00:00.000
	ReleaseDate <  dateadd(dd,datediff(dd,0,GETDATE())+1,0)	and
	StockQty > 0


CODO ERGO SUM
Go to Top of Page

taunt
Posting Yak Master

128 Posts

Posted - 06/11/2013 :  17:52:18  Show Profile  Reply with Quote
Hhhmmm I should have used CURDATE(). That worked fine. Thanks for your reply.

Edited by - taunt on 06/11/2013 17:52:58
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

USA
7020 Posts

Posted - 06/11/2013 :  21:58:38  Show Profile  Reply with Quote
If you wanted a MySQL solution, you should have posted on a MySQL forum.



CODO ERGO SUM
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.3 seconds. Powered By: Snitz Forums 2000