Display Data Less then to Date.

Analyst_SQL 3,576 Reputation points
2021-04-09T07:20:10.323+00:00

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

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
SQL Server | Other
0 comments No comments
{count} votes

Answer accepted by question author
  1. MelissaMa-msft 24,241 Reputation points Moderator
    2021-04-09T07:29:34.023+00:00

    Hi @Analyst_SQL ,

    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.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.