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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 GETDATE() in tsql look up

Author  Topic 

taunt
Posting Yak Master

128 Posts

Posted - 2013-06-11 : 17:31:45
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

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2013-06-11 : 17:45:12

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 - 2013-06-11 : 17:52:18
Hhhmmm I should have used CURDATE(). That worked fine. Thanks for your reply.
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2013-06-11 : 21:58:38
If you wanted a MySQL solution, you should have posted on a MySQL forum.



CODO ERGO SUM
Go to Top of Page
   

- Advertisement -