on 06-18-2009 4:27 PM
Prueba esta:
SELECT T0.DocEntry, T0.DueDate, (CASE WHEN MONTH(T0.DueDate) = '2' THEN 'Febrero' END) AS 'MES', T0.InstlmntID, T0.Status, (T0.InsTotal -T0.PaidToDate) as 'NNN' FROM INV6 T0 WHERE T0.Status = 'o' and month(T0.DueDate) = '02'
UNION
SELECT T0.DocEntry, T0.DueDate, (CASE WHEN MONTH(T0.DueDate) = '3' THEN 'Marzo' END) AS 'MES', T0.InstlmntID, T0.Status, (T0.InsTotal -T0.PaidToDate) as 'NNN' FROM INV6 T0 WHERE T0.Status = 'o' and month(T0.DueDate) = '03'
Saludos,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
La clausula month te permite extraer el mes (numero), asi que lo comparas con el mes que corresponda:
SELECT T0.[DocNum], T0.[DocDate] FROM OINV T0 WHERE month(T0.[DocDate]) = '01'
Saludos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Y ....
abusando de tu generosidad cómo le hago para unir estas dos consultas, ya traté con UNION y me marca error.
SELECT T0.DocEntry, T0.InstlmntID, T0.Status, (T0.InsTotal -T0.PaidToDate) as 'Febrero'FROM INV6 T0 WHERE T0.Status = 'o' and month(T0.DueDate) = '02'
SELECT T0.DocEntry, T0.InstlmntID, T0.Status, (T0.InsTotal -T0.PaidToDate) as 'Marzo'FROM INV6 T0 WHERE T0.Status = 'o' and month(T0.DueDate) = '03'
Saludos
Estimada Weena
Si no quieres usar Like entonces puedes usar la funcion DATEPART te dejo el link de la documentacion [http://msdn.microsoft.com/en-us/library/ms174420.aspx]
y tu parametro de entrada seria el numero de mes: 1= enero, 2 = febrero, 3 = marzo, etc.
Ejemplo:
DECLARE @MES INT
......
WHERE DATEPART(month, OINV.TaxDate) = @MES
Saludos
George
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
6 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.