| |

VerySource

 Forgot password?
 Register
Search
View: 853|Reply: 6

How to find all the data in the specified month as fast as possible?

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-21 09:30:01
| Show all posts |Read mode
data sheet:
ID DATETIME
1 2016-10-2
2 2016-10-12
3 2016-11-22
4 2016-12-17

What method can be used to find the data of 2016-10 as quickly as possible?
Reply

Use magic Report

0

Threads

93

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 China

Post time: 2020-6-26 23:30:01
| Show all posts
select * from ta where convert(varchar(7),[datetime],120)='2016-10'
Reply

Use magic Report

0

Threads

35

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-6-27 08:00:02
| Show all posts
--or
select * from ta where year([datetime])=2016 and month([datetime])=10
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-6-27 17:30:01
| Show all posts
select * from tbName where convert(char(7), DATETIME, 120)='2016-10'
Reply

Use magic Report

0

Threads

10

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 Invalid IP Address

Post time: 2020-6-29 23:45:01
| Show all posts
that's it
select * from TableName where convert(char(7), DateTime, 120)='2016-10'
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-7-2 17:45:01
| Show all posts
Ask, what parameter is 120, how can I not find the help document?

The problem is solved, thank you all!
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-2 18:45:01
| Show all posts
select * from tabName where datediff(month,dtTime,'2016-10-1') = 0
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