Matlab中的SQL:使用查询创建日期

时间:2018-01-18 19:44:24

标签: sql matlab date ms-access

我有每日数据:

     Isin             Date          Price   
 ______________    ____________    __________ 
'GB00B1YW4409'    '31.12.1999'    [688.1300]
'GB00B1YW4409'    '03.01.2000'    [688.1300]
'GB00B1YW4409'    '04.01.2000'    [690.6200]
'GB00B1YW4409'    '05.01.2000'    [666.9500]
'GB00B1YW4409'    '06.01.2000'    [650.7600]
'GB00B1YW4409'    '07.01.2000'    [663.2200]
'GB00B1YW4409'    '10.01.2000'    [694.3500]
'GB00B1YW4409'    '11.01.2000'    [683.7700]
'GB00B1YW4409'    '12.01.2000'    [675.0500]
'GB00B1YW4409'    '13.01.2000'    [664.4600]

我想要列出每个月的第一个。类似的东西:

'01.01.2000'
'01.02.2000'
'01.03.2000'

我想到了像

这样的东西
select distinct date(year(List.Date),month(List.Date),01) as Data from List

但我收到一条错误消息:

Error using COM.ADODB_Connection/Execute
Invoke Error, Dispatch Exception:

Source: Microsoft Access Database Engine

Description: Wrong number of arguments used with function in query expression

'date(year(List.Date),month(List.Date),01).

我做错了什么?

1 个答案:

答案 0 :(得分:1)

MS Access中的date()函数返回当前日期。

您正在寻找dateserial()

select distinct dateserial(year(List.Date), month(List.Date), 01) as Data
from List;