我相信我的编码有问题。我猜它不是按日期过滤的。请帮忙
SQL 代码:
SELECT
CONVERT(char(80), i.InvDate,3) AS InvDate,
i.InvoiceNo,
i.EmployerCode,
i.TaxAmount + i.SubTotal AS Amount,
'' AS Payment,
pd.GivenName
FROM
dbo.Invoice i
INNER JOIN
dbo.PatientDetails pd ON (pd.MedicalRecordID = i.MedicalRecordID)
C#代码:
SqlCommand objCmd = new SqlCommand("SELECT CONVERT(char(80), i.InvDate,3) AS InvDate,
i.InvoiceNo,
i.EmployerCode,
i.TaxAmount + i.SubTotal AS Amount,
'' AS Payment,
pd.GivenName
FROM
dbo.Invoice i
INNER JOIN dbo.PatientDetails pd ON (pd.MedicalRecordID = i.MedicalRecordID)
WHERE (InvDate >= CONVERT(datetime, '" + dtpFrom.Text + "', 105 ))
AND (InvDate <= CONVERT(datetime, '" + dtpTo.Text + "', 105))," , objConn);
这就是我想要实现的目标:
这就是我得到的:
在我被踢出这里之前。我会做一些编辑。
编辑:
日期时间为 105 格式 (dd-mm-yyyy)
WHERE (InvDate >= CONVERT(datetime, '" + dtpFrom.Text + "', 105 ))
AND (InvDate <= CONVERT(datetime, '" + dtpTo.Text + "', 105))
这应该从特定日期中选择。例如:2012 年 10 月 11 日至 2012 年 10 月 15 日。
即使没有 DateTimepicker,输出也不会显示“GivenName”