473,406 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

need urgent help


Hi,

I am creating a attendance sheet software for inhouse use.

my data is like this:-

------------------------------------------------------------------------------------------------
| name | login time | logout
time |
------------------------------------------------------------------------------------------------
| a | 2007-11-10 12:00:00 | 2007-11-10
16:00:00 |
------------------------------------------------------------------------------------------------
| b | 2007-11-10 15:00:00 | 2007-11-10
18:00:00 |
------------------------------------------------------------------------------------------------

My requirement:-

I want to generate an hourly report like this:-
--------------------------------------------------------------------------------------------
date time range total people logged
in
---------------------------------------------------------------------------------------------
2007-11-10 0 -2 0
--------------------------------------------------------------------------------------------
2007-12-10 2-4 0
--------------------------------------------------------------------------------------------
..
..
-------------------------------------------------------------------------------------------
2007-11-10 12-14 1
-------------------------------------------------------------------------------------------
2007-11-10 14-16 2
--------------------------------------------------------------------------------------------
2007-11-10 16-18 1
------------------------------------------------------------------------------------------------
..
..
---------------------------------------------------------------------------------------------
2007-11-10 22-24 0
--------------------------------------------------------------------------------------------
This is what I want to creat , but I don't know how can I generate
such kind of report.

Can you please guide me for the same. Please reply urgently.

Thanks & Regards,
Bhishm
Nov 20 '07 #1
2 1417
Hi Bhishm,

I'm afraid you will need to supply a lot more information than this.
What table(s) exist for storing these details? What technology are you
using to design the report? What does the "Time Range" value in the
report represent (looks like hours?) Do you simply need a SQL
Statement to prepare data in the "report" format you specified?

If I simply assume that everything un-said is as I imagine it, I guess
the solution might be something like:
/* Initialise data table */
CREATE TABLE tblLog (LogName nvarchar(50), LogInTime datetime,
LogOutTime datetime)

INSERT INTO tblLog (LogName, LogInTime, LogOutTime)
SELECT 'personA', '2007-11-10T12:00:00', '2007-11-10T16:00:00'
UNION ALL
SELECT 'personB', '2007-11-10T15:00:00', '2007-11-10T18:00:00'
UNION ALL
SELECT 'personC', '2007-11-10T11:00:00', '2007-11-10T14:00:00'

/* Create supporting table */
CREATE TABLE HrInDay (HrMin INT, HrMax INT, TimeRange VARCHAR(10))

DECLARE @i INT, @Date VARCHAR(8)

SET @i = 0
SET @Date = '20071110' -- Date parameter for "Report"

WHILE @i < 24
BEGIN
INSERT INTO HrInDay (HrMin, HrMax, TimeRange)
VALUES (@i, @i + 2, CAST(@i AS VARCHAR) + ' - ' + CAST(@i + 2 AS
VARCHAR))
SET @i = @i + 2
END

/* Select from a derived table so it's sorted - there is probably a
better way to do this but I'm too lazy to find it :) */
SELECT LogDate, TimeRange, NoPplLogged
FROM (
SELECT @Date AS LogDate,
MAX(TimeRange) AS TimeRange,
HrMin,
COUNT(DISTINCT LogName) AS NoPplLogged
FROM tblLog
RIGHT JOIN HrInDay
ON DATEPART(hh, LogInTime) < HrMax
AND DATEPART(hh, LogOutTime) HrMin
AND CONVERT(VARCHAR(8), LogInTime, 112) = @Date
GROUP BY HrMin
) AS Report

DROP TABLE HrInDay
DROP TABLE tblLog

Good luck!
J
Nov 20 '07 #2
Thanks a lot :) JhofM for showing the way.

I got a lot of help from it in solving it.

Now I am looking into possilities and will let you know my results.

Thanks a lot again, it's of great help
Nov 22 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jenny | last post by:
Need urgent help for an unsolved problem. In our ASP web application, we creat a Back button and if user click on this button, it execute history.go(-1) to go back to the previous page. All our...
3
by: Rahul S. | last post by:
Hey all: I need urgent information how to set the environment in Visual.NET wiritng in C. I am working with a licensed version of the Analyze 6.0 software from mayo clinic. I need to write...
16
by: | last post by:
Hi all, I have a website running on beta 2.0 on server 2003 web sp1 and I keep getting the following error:- Error In:...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
2
by: Max Power | last post by:
Hi All I am coding a small app in that swaps specific files between a client and server. All files and locations are set at both sides. I want my app to show a file list, based on the file...
1
by: TexCube | last post by:
Hello everyone, I have an urgent question. Can data be pulled from an access database table to create a directory that can be printed out and bound together? I need to have each row of a...
10
by: David Thielen | last post by:
Hi; I have help html pages for each page of my ASP.NET webapp. So for the page datasource.aspx, I have help\datasource.htm. Bu what I want when the hyperlink is clicked, for it to look for the...
0
by: sanjayhire | last post by:
Hi All, I have just joined the forum. I need your help..As it's very urgent... How to identify a particular process is running on a server(Windows/Unix server) using VB program and since how...
1
by: psantosh12 | last post by:
Hello Frnds Please need help to resolve error.......... it is very very urgent........ The error is Runtime Error Description: An application error occurred on the server. The current custom...
5
by: Justin | last post by:
Here's my XML: <?xml version="1.0" ?> <AppMode Type="Network"> <CurrentFolder Path="c:\tabs"> <Tabs> <FilePath>tabs\Justin.tab</FilePath> <FilePath>tabs\Julie.tab</FilePath> *****There could...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.