2021年3月31日星期三

Selecting between two dates

I was trying to select data between to dates starting from March 1 to March 31 of 2021 but it shows data from March 2020. This is the query I am using now:

SELECT        ROW_NUMBER() OVER (ORDER BY T.Payment_Date DESC),      FORMAT (Entry_Date, 'dd/MM/yyyy ') 'Entry Date',      FORMAT (Payment_Date, 'dd/MM/yyyy ') 'Paid Date'   FROM      Transes T   WHERE       Trx_Status = 1       AND Remit_Status = 3       AND (CONVERT(varchar(50), T.Payment_Date, 101) BETWEEN '03/01/2021' AND '03/31/2021')   ORDER BY      T.Payment_Date DESC  

The problem: instead of selecting between '03/01/2021' and '03/31/2021', it adds data from March 2020, it selects from 03/01/2021 to 03/27/2020 but only March Month.

What is the problem? Please help.

https://stackoverflow.com/questions/66897109/selecting-between-two-dates April 01, 2021 at 08:53AM

没有评论:

发表评论