如何选择上个月的postgres数据

时间:2018-01-30 10:02:53

标签: postgresql

我的数据带有Monday, January 29, 2018 12:00 AM日期,如何输出所有上次日期为| 1 | Monday, January 29, 2018 12:00 AM | | 2 | Monday, January 29, 2018 12:00 AM | | 3 | Monday, January 29, 2018 12:00 AM | | 4 | Monday, January 28, 2018 12:00 AM | | 5 | Monday, January 28, 2018 12:00 AM | | 6 | Monday, January 28, 2018 12:00 AM | | 7 | Monday, January 27, 2018 12:00 AM | | 8 | Monday, January 27, 2018 12:00 AM | | 9 | Monday, January 27, 2018 12:00 AM | 的记录?

import numpy as np

x = np.array([1, 3, 6, 1, -5, 6, 4, 1, 6])

def running_diff(arr, N):
    return np.array([arr[i] - arr[i-N] for i in range(N, len(arr))])

running_diff(x, 4)  # array([-6,  3, -2,  0, 11])

1 个答案:

答案 0 :(得分:0)

这应该适合你:

select * from table where extract(dow from date_field) = 1 

1是星期一 7是星期天