SELECT
incident.createDate,
LEFT(incident.createDate,11)as EntryDate,
ContactDetails.cityCode,
patient.insurance,
FROM ......
WHERE
incident.createDate Between Convert(smalldatetime, '01/07/2012', 103) and Convert(smalldatetime, '31/12/2012', 103)
and servicecharges.serviceid = 31
and ServiceRequestDescription LIKE '05.06%'
and chargeDescr = 'Ε0 50.01'
and incident.status != 6
order by createDate ASC, contactdetails.cityCode ASC, patient.insurance ASC
作为输出我得到了
15642 2012-08-03 11:45:07.153 Aug 3 2012 103 15
我想得到的是
15642 2012-08-03 103 15
EntryDate如上所示投射日期,所以我不想要它。订购也错了。它使用日期正确地命令输出,但是城市代码和保险不正确..
有什么想法吗?
答案 0 :(得分:0)
试试这个
SELECT
...
CONVERT(Varchar, incident.createDate, 103) as EntryDate,
ContactDetails.cityCode,
patient.insurance,
FROM ......
答案 1 :(得分:0)
对于Sql-Server:我认为没有direct format来获取 ONLY
yyyy-mm-dd
。您可以尝试 120/121
,然后获取 left 10 characters
,如下所示。小demo here。
select left(convert(varchar,incident.createDate,120),10) as EntryDate