| |

VerySource

 Forgot password?
 Register
Search
Author: zhuxuewei110

Ask time to deal with the problem

[Copy link]

0

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-4-11 20:15:02
| Show all posts
create table T (f1 int, f2 datetime)
insert T select 1, '2016-12-20 22: 22: 32.000'
union all select 2, '2016-12-20 23: 32: 38.000'
union all select 3, '2016-12-20 00: 24: 49.000'

select f2 from T where
DATEDIFF (Hour, Convert (char (8), f2,112), f2) in (23,0)
and
(DATEDIFF (Minute, Convert (char (10), f2,112), f2) -DATEDIFF (Hour, Convert (char (8), f2,112), f2) * 60)
between 0 and 59
Reply

Use magic Report

0

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-4-12 10:15:01
| Show all posts
create table T (f1 int, f2 datetime)
insert T select 1, '2016-12-20 22: 22: 32.000'
union all select 2, '2016-12-20 23: 32: 38.000'
union all select 3, '2016-12-20 00: 24: 49.000'
union all select 4, '2016/12/28 00: 34: 11.000'

select f2 from T where
(DATEDIFF (Hour, Convert (char (8), f2,112), f2) = 23
and
(DATEDIFF (Minute, Convert (char (10), f2,112), f2) -DATEDIFF (Hour, Convert (char (8), f2,112), f2) * 60)
between 0 and 59)
or
(DATEDIFF (Hour, Convert (char (8), f2,112), f2) = 0
and
(DATEDIFF (Minute, Convert (char (10), f2,112), f2) -DATEDIFF (Hour, Convert (char (8), f2,112), f2) * 60)
between 0 and 30)
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 Invalid IP Address

Post time: 2020-4-17 08:30:02
| Show all posts
The record of the time part of the field f2 in the range of t1 to t2? LZ You are not very clear.
   2016-12-20 00: 24: 49.000
   2016-12-20 23: 34: 49.000
   2016-12-19 23: 34: 49.000
   2016-12-19 00: 24: 49.000
What are the records between 00:30 and 23:30?
Reply

Use magic Report

1

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-5-5 22:00:01
| Show all posts
dazhuzhu1h:
 23:30 is yesterday, 00:30 is today, which is in the following time records
   2016-12-20 00: 24: 49.000
   2016-12-20 23: 34: 49.000
   2016-12-19 23: 34: 49.000
   2016-12-19 00: 24: 49.000
   2016-12-20 00: 24: 49.000
   2016-12-20 23: 14: 49.000
   2016-12-19 00: 34: 49.000
   2016-12-19 23: 24: 49.000
 Shuai selected the record with the time range from 23:30 yesterday to 00.:30 the next day. I want to get the result:
   2016-12-20 23: 34: 49.000
   2016-12-19 23: 34: 49.000
   2016-12-19 00: 24: 49.000
   2016-12-20 00: 24: 49.000
 Only the time part does not matter the date part.
Reply

Use magic Report

1

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-5-7 15:00:02
| Show all posts
The defined t1 may be another time, it may be 22:30 or 21:15 on the first day, etc.
The defined t2 may be another time, it may be 01:30 or 02:15 the next day, etc.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list