Ver Mensaje Individual
  #2 (permalink)  
Antiguo 25/10/2011, 12:11
Avatar de Libras
Libras
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 17 años, 8 meses
Puntos: 774
Respuesta: Fechas en Sql

Código SQL:
Ver original
  1. DECLARE @dia INT
  2. DECLARE @mes INT
  3. DECLARE @x INT
  4. DECLARE @fecha datetime
  5. DECLARE @dias TABLE (dia datetime)
  6. SET @fecha='10/01/2011'
  7. SET @dia=datepart(dd,@fecha)
  8. SET @x=datepart(mm,@fecha)
  9. SET @mes=datepart(mm,@fecha)  
  10. while @x=@mes
  11. BEGIN
  12.     INSERT INTO @dias VALUES (@fecha)
  13.     SET @fecha=dateadd(dd,1,@fecha)  
  14.     SET @mes=datepart(mm,@fecha)  
  15. END
  16. SELECT * FROM @dias

Saludos!
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me