商品上架时间设计跨天的查询

 1 SELECT  *
 2 FROM    C
 3                                         WHERE ( 1 = CASE WHEN c.vcStartTime < c.vcEndTime
 4                                                        THEN ( CASE
 5                                                               WHEN CONVERT(VARCHAR(5), GETDATE(), 8) BETWEEN c.vcStartTime
 6                                                               AND
 7                                                               c.vcEndTime
 8                                                               THEN 1
 9                                                               ELSE 0
10                                                               END )
11                                                        ELSE ( CASE
12                                                               WHEN CONVERT(VARCHAR(5), GETDATE(), 8) >= c.vcStartTime
13                                                               OR CONVERT(VARCHAR(5), GETDATE(), 8) <= c.vcEndTime
14                                                               THEN 1
15                                                               ELSE 0
16                                                               END )
17                                                   END )

 

posted @ 2015-08-28 14:14  liuliu_刘刘  阅读(209)  评论(0编辑  收藏  举报