| |

VerySource

 Forgot password?
 Register
Search
View: 700|Reply: 4

Query all records that satisfy two time fields in the database

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-30 17:20:02
| Show all posts |Read mode
I have two time fields (startdate and enddate) in Table A to record the start and end dates of the contract. Now I also enter the start time and end time on the page for query. come out?
Reply

Use magic Report

0

Threads

49

Posts

35.00

Credits

Newbie

Rank: 1

Credits
35.00

 China

Post time: 2020-3-7 15:45:01
| Show all posts
What conditions are met?
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-3-10 14:15:01
| Show all posts
solved
declare @b datetime
set @b = '2017-01-01'
declare @e datetime
set @e = '2017-12-01'
Select * from table where (@b between StateDate and EndDate or @e between StateDate and EndDate)
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 China

Post time: 2020-3-11 17:00:01
| Show all posts
declare @b datetime
set @b = '2017-01-01'
declare @e datetime
set @e = '2017-12-01'
Select * from Table: Where StartDate> = @ b and EndDate <= @ e
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-3-21 14:30:01
| Show all posts
Oh it should be so comprehensive
declare @b datetime
set @b = '2017-01-01'
declare @e datetime
set @e = '2017-12-01'
Select * from table
@b between StartDate and EndDate or @e between StartDate and EndDate or startdate> = @ b and enddate <= @ e
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