"Select * From CashReport where convert(varchar(10),StartDate,101)>=@pStartDate and Convert(varchar(10),EndDate,101)<=@pEndDate and Type = 'I'"

Hello! i want to add CUSTOMER NAME in this code how to view each customer datewise report plz help me..

Dani AI

Generated

As requested per-customer, date-range output (and asked for clarification), the cleanest approach is to return customer name from the query (join your customer table) and use true date/datetime parameters instead of converting date columns to strings. Converting the column in the WHERE clause prevents index use and often causes wrong or slow results.

A typical dataset query pattern:

SELECT c.CustomerName, cr.*
FROM CashReport cr
INNER JOIN Customers c ON cr.CustomerID = c.CustomerID
WHERE cr.StartDate >= @StartDate
  AND cr.StartDate < DATEADD(day, 1, @EndDate)
  AND cr.Type = 'I'
ORDER BY c.CustomerName, cr.StartDate;

Use the exclusive end-date pattern (< DATEADD(day,1,@EndDate)) to include all rows on the end day when StartDate has a time component. If a report row represents a date range and you want any overlap with the selected range, use overlap logic: cr.StartDate <= @EndDate AND cr.EndDate >= @StartDate. Pass @StartDate and @EndDate into ReportViewer as Date/DateTime parameters (not strings) or call a stored procedure that accepts typed parameters. Troubleshoot missing rows by previewing parameter values and checking for time parts or parameter type mismatches.

See the SQL docs on CAST/CONVERT and date/time functions for details on types and functions:
CAST and CONVERT (Transact-SQL)

Recommended Answers

All 2 Replies

Need a little more explanation. What do you mean by add customer name?

i need to view Each customer information with dates.........i m using microsoft report viewer

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.