Ver Mensaje Individual
  #3 (permalink)  
Antiguo 01/06/2011, 11:15
carlozvega2
 
Fecha de Ingreso: julio-2010
Mensajes: 4
Antigüedad: 13 años, 9 meses
Puntos: 0
Respuesta: Definiendo valores datetime

Cita:
Iniciado por Libras Ver Mensaje
Cual es tu codigo?? y para sacar con la fecha exacta creo que pudieras convertir tu fecha en un formato dd/mm/yyyy y asi no tendrias problemas con las horas, ya que todo lo que caiga en un dia incluye tooooodo el dia :)

Saludos!
El procedure viene a ser el siguiente, los comparto a todos. El procedure funciona muy bien, lo que me explicas lo entiendo en oracle es mas sencillo dicho formateo en la fecha pero en Sql Server 2000 no sé exactamente ese mecanismo... si lo pudieras explicar con ejemplo me serviria. Thank...


CREATE PROCEDURE sp_obtenerFecha
@dateRecivido datetime,
@opcion int,
@dateReturn datetime OUTPUT
AS

DECLARE @fechaSistema datetime
DECLARE @auxYear int
DECLARE @auxMonth int
DECLARE @auxDay int
DECLARE @Year varchar(4)
DECLARE @Month varchar(2)
DECLARE @Day varchar(2)
DECLARE @fechaExtacta datetime

DECLARE @fechaPrueba varchar(23)

SET LANGUAGE English

SET @fechaSistema = @dateRecivido

SET @auxYear = YEAR(@fechaSistema)
SET @auxMonth = MONTH(@fechaSistema)
SET @auxDay = DAY(@fechaSistema)

IF 1 = (select LEN(@auxDay))
BEGIN
SET @Day = '0'+CAST(@auxDay as varchar(1))
END
ELSE
BEGIN
SET @Day = CAST(@auxDay as varchar(2))
END

IF 1 = (select LEN(@auxMonth))
BEGIN
SET @Month = '0'+CAST(@auxMonth as varchar(1))
END
ELSE
BEGIN
SET @Month = CAST(@auxMonth as varchar(2))
END

SET @Year = CAST(@auxYear as varchar(4))

IF @opcion = 1
BEGIN
SET @fechaPrueba = (@Year+'-'+@Month+'-'+@Day+' 00:00:00.000')
END
ELSE
BEGIN
SET @fechaPrueba = (@Year+'-'+@Month+'-'+@Day+' 23:59:59.997')
END

SET @dateReturn = CONVERT( datetime, @fechaPrueba)
GO



EJECUTAR EL PROCEDURE :
DECLARE @fecha_inicio as datetime
SET @fecha_inicio = getdate()


DECLARE @dateInicio datetime
DECLARE @dateFin datetime
DECLARE @opIni int
DECLARE @opFin int
SET @opIni = 1
SET @opFin = 2
EXEC sp_obtenerFecha @fecha_inicio, @opIni, @dateInicio OUTPUT
EXEC sp_obtenerFecha @fecha_inicio, @opFin, @dateFin OUTPUT