| |

VerySource

 Forgot password?
 Register
Search
View: 856|Reply: 9

Solving LIKE problems online

[Copy link]

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-2 18:00:01
| Show all posts |Read mode
A field in the ACCESS database is a date type, and stores the complete time, including year, month, day, hour, minute, and second.
When searching, I need to find the records that meet the conditions, how should I use LIKE?
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-5-13 00:15:01
| Show all posts
select * from tablename where ddate between # 2017-1-1 00: 00: 01 # and # 2017-1-4 23: 59: 59 #
Reply

Use magic Report

1

Threads

12

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-5-19 01:00:01
| Show all posts
You can convert the date type into a fixed format string in SQL query, so that you can query not only a certain day, but also a certain year, a month, a certain time, a certain second, because I have been programming under SQLServer2000 , I don't know the SQL functions related to ACCESS, please also masters to give these functions
    Write this in SQL Server 2000:
    select * from table name where convert (char (10), date field, 120) = '2017-01-05'
Reply

Use magic Report

0

Threads

9

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-5-19 16:45:01
| Show all posts
format for access:

select * from tb
where format (youDate, "yyyy-mm") = '2016-12'
Reply

Use magic Report

0

Threads

9

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-5-19 17:45:01
| Show all posts
format for access:

select * from tb
where format (youDate, "yyyy-mm-dd") = '2016-12-25'
Reply

Use magic Report

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 United States

 Author| Post time: 2020-5-24 21:15:01
| Show all posts
restajufehyg

According to your wording, the prompt type does not match, is it because there is a null value in the date field?
Reply

Use magic Report

1

Threads

12

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-5-26 09:15:01
| Show all posts
Conditions can be added:
 and not date field is null
Reply

Use magic Report

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-5-28 16:15:01
| Show all posts
I wrote it this way. I beg your boss to see what went wrong.

RS.Open "select * from TB1 where" + Format ([D_Field], "yyyy-mm-dd") + "= '" + Format (Now, "yyyy-mm-dd") + "'", CN, adOpenDynamic, adLockBatchOptimistic
Reply

Use magic Report

1

Threads

12

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-6-2 12:30:01
| Show all posts
RS.Open "select * from TB1 where Format([D_Field],'yyyy-mm-dd') ='" + Format(Now, "yyyy-mm-dd") + "'", CN, adOpenDynamic, adLockBatchOptimistic

This should be right, because I don't have ACCESS, so I can't debug, but I see the basic problems when you write
Reply

Use magic Report

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-6-7 09:30:01
| Show all posts
Problem solving, thank you teachers.
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