skip to Main Content

I have query:

expiration >: '01-01-2022' and expiration <:  '09-01-2022'

My database:

id | customer_id | type | expiration |
1  | 1           | Test | 03-01-2022 |
2  | 2           |Test2 | 05-01-2022 |
3  | 3           |Test3 | 05-05-2022 |

I want to receive :

1  | 1 | Test | 03-01-2022 |
2  | 2 |Test2 | 05-01-2022 |

But, I get:

1  | 1 | Test | 03-01-2022 |
2  | 2 |Test2 | 05-01-2022 |
3  | 3 |Test3 | 05-05-2022 |

Can you help me?

2

Answers


  1. Chosen as BEST ANSWER

    I changed the format and now it searches correctly)

    Was: dd-MM-yyyy
    Now: yyyy-MM-dd
    

  2. I don’t know what dialect of SQL you are using. But the query looks fine except unusual operators >: and <:. Why not use >= and <=.

    I would recommend to look into datetime format used. Is it DD-MM-YYYY, or MM-DD-YYYY? It depends on your database locale. The most usual format is YYYY-MM-DD, but that’s probably not your case, because it would select nothing.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search