question

akhterhussain-3167 avatar image
0 Votes"
akhterhussain-3167 asked MelissaMa-msft edited

Display Data Less then to Date.

I want to display data before date ,but it is displaying greater then that date

 select M.Sell_ID,M.E_Date,M.Level_Four_ID as ID,(isnull(cast(M.Sell_Amt as float),0))-(isnull(cast(R.Rec_Amt as float),0))as  Pending
  from tbl_Sell_M M inner join tbl_Received_Amount R on R.Sell_ID=M.Sell_ID
 where M.E_Date<'2021-03-01'  and M.Level_Four_ID=320222
 --group by M.Level_Four_ID


Result is

86087-image.png


sql-server-generalsql-server-transact-sql
image.png (5.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MelissaMa-msft avatar image
0 Votes"
MelissaMa-msft answered MelissaMa-msft edited

Hi @akhterhussain-3167,

We recommend that you post CREATE TABLE statements for your tables together with INSERT statements with sample data, enough to illustrate all angles of the problem. We also need to see the expected result of the sample.

I also found that your E_Date was in 2020 while your condition was less than one date in 2021. Please double check the years.

You could have a try with below:

 where E_Date<'2020-03-01' 

Or:

 where E_Date<cast('2020-03-01' as date)

Best regards
Melissa


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.