Warm tip: This article is reproduced from serverfault.com, please click

How can I combine date with WHERE clause

发布于 2020-11-28 16:03:16

I have a WHERE condition and i want filter two reports in first I want to onlu have items from 2020 year and in the other from 2019 I m trying to write it like this:

[UMOWY]![data_wygasniecia]>#01.01.2019#<#01.01.2020#

AND In 2020

[UMOWY]![data_wygasniecia]>#01.01.2020#<#01.01.2021#

But it doesnt work, my table is UMOWY and and the column name is data_wygasniecia the date is stored in date format. Can you please help?

https://imgur.com/a/H5ZFwme photo where how where i try

Questioner
Mateusz Jablonski
Viewed
1
Gustav 2020-11-29 00:39:05

Use the correct syntax for date expressions:

[UMOWY]![data_wygasniecia] Between #2019/01/01# And #2019/12/31#

or, if a time component is present:

[UMOWY]![data_wygasniecia] >= #2019/01/01# 
And
[UMOWY]![data_wygasniecia] < #2020/01/01#

or, if the recordset isn't too large:

Year([UMOWY]![data_wygasniecia]) = 2019