如何在 Redshift 中获取 generate_series() 函数以仅生成日期而不是日期时间
How to get generate_series() function in Redshift to result in just dates NOT date-time
有没有办法删除结果集上的时间戳?
这是我在 Redshift 中 运行 的查询:
SELECT CURRENT_DATE - (i * interval '1 day') as dates
FROM generate_series(0,7) i
ORDER BY 1;
这是结果:
1
2020-10-21T00:00:00.000Z
2
2020-10-22T00:00:00.000Z
3
2020-10-23T00:00:00.000Z
4
2020-10-24T00:00:00.000Z
5
2020-10-25T00:00:00.000Z
6
2020-10-26T00:00:00.000Z
7
2020-10-27T00:00:00.000Z
8
2020-10-28T00:00:00.000Z
刚投:
SELECT cast(current_date - i * interval '1 day' as date) as dates
FROM generate_series(0, 7) i
ORDER BY 1;
或者:
SELECT (current_date - i * interval '1 day')::date as dates
FROM generate_series(0, 7) i
ORDER BY 1;
有没有办法删除结果集上的时间戳?
这是我在 Redshift 中 运行 的查询:
SELECT CURRENT_DATE - (i * interval '1 day') as dates
FROM generate_series(0,7) i
ORDER BY 1;
这是结果:
1
2020-10-21T00:00:00.000Z
2
2020-10-22T00:00:00.000Z
3
2020-10-23T00:00:00.000Z
4
2020-10-24T00:00:00.000Z
5
2020-10-25T00:00:00.000Z
6
2020-10-26T00:00:00.000Z
7
2020-10-27T00:00:00.000Z
8
2020-10-28T00:00:00.000Z
刚投:
SELECT cast(current_date - i * interval '1 day' as date) as dates
FROM generate_series(0, 7) i
ORDER BY 1;
或者:
SELECT (current_date - i * interval '1 day')::date as dates
FROM generate_series(0, 7) i
ORDER BY 1;