Ver Mensaje Individual
  #5 (permalink)  
Antiguo 25/04/2012, 08:37
Avatar de Libras
Libras
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 18 años, 4 meses
Puntos: 774
Respuesta: instruccion para fecha

Cita:
Iniciado por jerrymix Ver Mensaje
no entendi donde debere poner el where
Madre mia que pregunta :S

Código SQL:
Ver original
  1. SELECT CASE WHEN Datepart(MONTH, T0.DocDate) = 1
  2. THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-01 ' WHEN Datepart(MONTH, T0.DocDate)= 2
  3. THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-02 ' WHEN Datepart(MONTH, T0.DocDate)= 3
  4. THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-03 ' WHEN Datepart(MONTH, T0.DocDate)= 4
  5. THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-04 ' WHEN Datepart(MONTH, T0.DocDate)= 5
  6. THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-05 ' WHEN Datepart(MONTH, T0.DocDate)= 6
  7. THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-06 ' WHEN Datepart(MONTH, T0.DocDate)= 7
  8. THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-07 ' WHEN Datepart(MONTH, T0.DocDate)= 8
  9. THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-08 ' WHEN Datepart(MONTH, T0.DocDate)= 9
  10. THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-09 ' WHEN Datepart(MONTH, T0.DocDate)= 10
  11. THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-10 ' WHEN Datepart(MONTH, T0.DocDate)= 11
  12. THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-11 ' WHEN Datepart(MONTH, T0.DocDate)= 12
  13. THEN CAST(Datepart(YEAR, T0.DocDate) AS VARCHAR(30)) + '-12 ' ELSE 'bones' END AS 'Periodo' WHERE YEAR(tucolumna) >= 2012 AND datepart(mm,tucolumna) >=4

En el query viene lo del mes tambien :)
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me