Hi, I’m creating a very simple report based on a SQL table, I’m unable to proper format the report and also I do not know how to filter it.
This is the table:
This is the report:
This is how it looks:
and this is the sample data:
My questions:
1.- How do I make the report to properly format date and time? It only shows dates and not time
2.- How do I make the report to fill the null values as empty columns?
If you want to use a view, in your where clause you can pass ‘{Start}’ and ‘{End}’ and those will be replaced with the date constraints behind the scenes.
I can’t get REPORT SQL DETAILS to work when formatting dates. So this is what I did:
Create a script:
code
DECLARE @StartDate NVARCHAR(25) = N'{Start}';
DECLARE @EndDate NVARCHAR(25) = N'{End}';
SELECT UserId,
UserName,
ISNULL(FORMAT(ClockIn, 'dd/MM/yyyy hh:mm:ss'), 'N/A') AS ClockIn,
ISNULL(FORMAT(ClockOut, 'dd/MM/yyyy hh:mm:ss'), 'N/A') AS ClockOut,
ISNULL(CONVERT(NVARCHAR(28), TotalHours), 'N/A') AS TotalHours
FROM dbo.ABR_ClockLog
WHERE ClockIn
BETWEEN @StartDate AND @EndDate
ORDER BY Id;
I just figured out that those parameters {Start} and {End} are based on the Work Period records, which in my opinion is a wrong approach, this is the reason why it defaults to those dates and times:
{Start} and {End} should be replaced with what range is specified in the report viewer.
IIRC, one can’t specify a date that is before the earliest work period and defaults back to the current work period or the earliest work period (can’t recall which).
It will work if you filter with date and time on the right.
The report screen is build around work periods. Work periods exist to designate reporting start and end dates. Many restaurants work past an actual day.
If you are trying to use it for shifts like time clock shifts it may not work how you think and you may need to build a screen that can filter exact date input easier.
However you can type a time after the date filter that’s on the right side of report screen to get exact date time filter.