小编Cat*_*155的帖子

Sqlalchemy在时段中获得排名

我有一个叫做约会的模型,它的列datetime是一个DateTime字段,duration它是一个Integer字段,代表持续时间,以分钟为单位.现在我要检查,如果func.now()是与datetime任命和的总和datetimeduration

我目前正试图这样做,但我需要一个适用于PostgreSQL和SQLite的解决方案.

current_appointment = Appointment.query.filter(
    Appointment.datetime.between(
        func.now(),
        func.timestampadd(
            'MINUTES', Appointment.duration, func.now()
            )
        )
    ).limit(1).one_or_none()
Run Code Online (Sandbox Code Playgroud)

python sqlite postgresql sqlalchemy python-3.x

6
推荐指数
1
解决办法
232
查看次数

Rust chrono提供ParseError(NotEnough)

我正在尝试将日期时间字符串解析为DateTime对象,但是当我尝试这样做时,我正在获取此ParseError。我不知道发生了什么,有人可以帮我吗?

日期时间字符串: 09-January-2018 12:00:00

码: let date = DateTime::parse_from_str(date.trim(), "%d-%B-%Y %T");

datetime datetime-format rust rust-chrono

2
推荐指数
1
解决办法
715
查看次数