Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Executing a stored procedure with a datetime parameter!

Status
Not open for further replies.

bricenoej

Programmer
Mar 19, 2002
50
VE
Hi guys! how are you! i need a help from you
I am trying to execute a stored procedure with some of parameters declare like a datetime,i want to filter two register from some date to some date and the problem is when i executed it did not come any record.
What do I have to do to show the record filter between the two date
Thanks for your help!

I show you the Code below:


ALTER PROCEDURE cc_Reportes_Suscriptores_Activados
(@PKServicio int,
@PKMercado int,
@FecActivacionDesde datetime,
@FecActivacionHasta datetime
)

AS
Begin


SELECT dbo.CUENTA.Cuenta, dbo.SUSCRIPTOR.Subscriberid, dbo.SUSCRIPTOR.IMSI, dbo.SUSCRIPTOR.FecActivacion, dbo.RATEPLAN.NombrePlan,
dbo.VASERVICIOS.VAServicio, dbo.REFERENCIA.Direccion_Correspondencia, dbo.REFERENCIA.Ciudad_Correspondencia,
dbo.REFERENCIA.Estado_Correspondencia, dbo.REFERENCIABANCARIAS.TipoDocumento, dbo.SUSCRIPTOR.FKServicio,
dbo.SUSCRIPTOR.FKMercado
FROM dbo.VASERVICIOSxSUSCRIPTOR INNER JOIN
dbo.VASERVICIOS ON dbo.VASERVICIOSxSUSCRIPTOR.FKVAServicio = dbo.VASERVICIOS.PKVAServicio INNER JOIN
dbo.CUENTA INNER JOIN
dbo.REFERENCIA ON dbo.CUENTA.PKCliente = dbo.REFERENCIA.FKCliente AND dbo.CUENTA.PKCliente = dbo.REFERENCIA.FKCliente INNER JOIN
dbo.SUSCRIPTOR ON dbo.CUENTA.PKCliente = dbo.SUSCRIPTOR.FKCliente INNER JOIN
dbo.RATEPLAN ON dbo.SUSCRIPTOR.FKRatePlan = dbo.RATEPLAN.PKRatePlan ON
dbo.VASERVICIOSxSUSCRIPTOR.FKSuscriptor = dbo.SUSCRIPTOR.PKSuscriptor INNER JOIN
dbo.REFERENCIABANCARIAS ON dbo.CUENTA.PKCliente = dbo.REFERENCIABANCARIAS.FKCliente
WHERE (dbo.SUSCRIPTOR.FKServicio = @PKServicio) AND (dbo.SUSCRIPTOR.FKMercado = @PKMercado)AND (dbo.SUSCRIPTOR.FecActivacion = CONVERT(DATETIME,@FecActivacionDesde, 102))AND (dbo.SUSCRIPTOR.FecActivacion = CONVERT(DATETIME, @FecActivacionHasta, 102))

I executed the procedure like this:

go
exec cc_Reportes_Suscriptores_Activados 1,1, '01/09/02','30/09/02'
 
You are selecting record on the exact dates rather than between them:

(dbo.SUSCRIPTOR.FecActivacion = CONVERT(DATETIME,@FecActivacionDesde, 102)) AND (dbo.SUSCRIPTOR.FecActivacion = CONVERT(DATETIME, @FecActivacionHasta, 102))

I think what you require is:

(dbo.SUSCRIPTOR.FecActivacion >= CONVERT(DATETIME,@FecActivacionDesde, 102))AND (dbo.SUSCRIPTOR.FecActivacion <= CONVERT(DATETIME, @FecActivacionHasta, 102))

Hope this helps,

Chris Dukes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top