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
 General SQL Server Forums
 New to SQL Server Programming
 Sp and getting date = today

Author  Topic 

Pinto
Aged Yak Warrior

590 Posts

Posted - 2010-10-04 : 08:09:58
I have the folowing stored procedure which compiles fine but does not return the required records. It does not return anything. In my sql table the date is stored liked this where it is dd/mm/yyyy and is datetime

04/10/2010 00:00:00

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
alter PROCEDURE [dbo].[spPP_GetRemindMeCases2]
-- Add the parameters for the stored procedure here

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
SELECT * from tblPP_Cases WHERE CA_RemindMe = getdate() and
CA_Completed = 0
order by CA_RemindMe asc
END

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-04 : 08:13:30
quote:
Originally posted by Pinto

I have the folowing stored procedure which compiles fine but does not return the required records. It does not return anything. In my sql table the date is stored liked this where it is dd/mm/yyyy and is datetime

04/10/2010 00:00:00

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
alter PROCEDURE [dbo].[spPP_GetRemindMeCases2]
-- Add the parameters for the stored procedure here

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
SELECT * from tblPP_Cases WHERE CA_RemindMe = dateadd(d,datediff(d,0,getdate()),0) and
CA_Completed = 0
order by CA_RemindMe asc
END




No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Pinto
Aged Yak Warrior

590 Posts

Posted - 2010-10-04 : 08:18:28
Thank you :-)
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-04 : 08:26:52
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-10-04 : 09:34:30
will work so long as you've no time part stored in your table.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-10-05 : 06:16:16
If it has timepart too,

use

CA_RemindMe >= dateadd(d,datediff(d,0,getdate()),0)
and
CA_RemindMe < dateadd(d,datediff(d,0,getdate())+1,0)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -