约 1 分钟阅读
数据库

时间比较时,比较交叉的情况

1

时间比较时,比较交叉的情况
SYSTEM更新于 May 20, 2024
84 次阅读约 1 分钟阅读

很典型的问题,正难则反

比如两个时间交叉的情况有这些:

PLAINTEXT
           |-------------------|          compare to this one
               |---------|                contained within
           |----------|                   contained within, equal start
                   |-----------|          contained within, equal end
           |-------------------|          contained within, equal start+end
     |------------|                       not fully contained, overlaps start
                   |---------------|      not fully contained, overlaps end
     |-------------------------|          overlaps start, bigger
           |-----------------------|      overlaps end, bigger
     |------------------------------|     overlaps entire period

而比较两个时间没有交集的就清晰简单的多:

PLAINTEXT
           |-------------------|          compare to this one
     |---|                                ends before
                                 |---|    starts after

所以这样处理问题来说就会简单很多

评论交流

暂无评论,欢迎分享您的见解