March 28, 2005 at 10:23 am
Hi,
I'm trying to get the system date but not the time in stored procedure but the it's not working. No records returned.
Could someone provide some input?
TIA!
CREATE PROCEDURE dbo.spHMshipping_rpt
AS
SELECT dbo.tblShipping_priorities.priority_desc, ... FROM dbo.tblShipping_priorities INNER JOIN dbo.tblShipping_sched ON dbo.tblShipping_priorities.ship_priority = dbo.tblShipping_sched.ship_priority
WHERE dbo.tblShipping_sched.cust_ord_due = getdate()
GO
March 28, 2005 at 10:29 am
I think your problem is cust_ord_due = '2005-03-28' AND GetDate() = '2005-03-28 12:14:00.000'
Change your code to be CONVERT(VARCHAR(10), GETDATE(), 101) and your code should work. If you want to WRAP the above to be D/T again place CAST(code from above AS DATETIME)...
Good Hunting!
AJ Ahrens
webmaster@kritter.net
March 28, 2005 at 10:58 am
Thank you! That works.
March 29, 2005 at 4:20 am
Another way would be:
cust_ord_due = dateadd(d,0,datediff(d,0,getdate()))
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
March 29, 2005 at 6:44 am
I'll make a note of that.
Thanks!
March 29, 2005 at 6:50 am
In that case, you might want to add
SELECT DATEADD(d,DATEDIFF(d,0,getdate()),0)
SELECT CAST(SUBSTRING(CAST(GETDATE() AS BINARY(8)),1,4) + 0x00000000 AS DATETIME)
SELECT CAST(CAST(SUBSTRING(CAST(GETDATE() AS binary(8)),1,4) AS INT) AS DATETIME)
SELECT CONVERT(DATETIME,CONVERT(CHAR(8),GETDATE(),112))
SELECT CONVERT(CHAR(8),GETDATE(),112)
SELECT CAST(CAST(GETDATE() AS VARCHAR(12)) AS DATETIME)
SELECT CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)
to that note
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
March 29, 2005 at 6:58 am
Thanks, Frank!
March 30, 2005 at 1:18 am
select
CONVERT(VARCHAR(10), GETDATE(), 23) by this you get the desired format as 2005-03-30 try it
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply