| |

VerySource

 Forgot password?
 Register
Search
View: 931|Reply: 5

Find the data after the filtering time?

[Copy link]

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-2-10 12:00:03
| Show all posts |Read mode
As table (TalbeA):
id title addtime
1 abc 2016-2-3
.
.
.
Need to take seven pieces of data:
Take seven data from addtime today. If it is insufficient, take yesterday's data. Otherwise, take the past 2 days, and so on, and make sure to make up seven data.
Thank you!
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-4-4 09:00:02
| Show all posts
--try

select top 7 * from TalbeA
where addtime <= getdate ()
order by addtime desc
Reply

Use magic Report

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-4-4 14:15:01
| Show all posts
@fanfan1980
Thanks

Ugh! I'm so dizzy (I'm too stupid)
Reply

Use magic Report

0

Threads

114

Posts

69.00

Credits

Newbie

Rank: 1

Credits
69.00

 China

Post time: 2020-4-4 15:45:01
| Show all posts
select * from TalbeA
where addtime in (select top 7 addtime from TalbeA order by addtime desc)
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 Japan

Post time: 2020-4-4 16:15:01
| Show all posts
select top 7 * from TalbeA
where addtime <convert (char (10), getdate () + 1,102)
order by addtime desc
Reply

Use magic Report

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-4-5 12:30:02
| Show all posts
It ’s too simple, I ’m all dizzy. I ’m obviously ranked today. . . I am dizzy.
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