473,386 Members | 1,835 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,386 software developers and data experts.

Time intervals from a single record.

Hello,I have a database that records leaves taken by employees.Every
record has employee name,leavefrom(to record the starting date of
leave) & leaveupto( for the leave end date).My requirement is to find
out monthwise, the no of days of leave taken by an employee.The problem
comes when the end date falls in the subsequent month of start date.Ex:
say an employee Mr. X takes leave from 29-Oct-06 to 03-Nov-06.I need an
output like the following:

Emp Name Month Leaves taken
X Oct2006 3
X Nov2006 3

(for the above dates)

I have tried making two queries with a month criteria but can't get an
output like the one given above.Please help.

Nov 4 '06 #1
4 1398
P.Jaimal wrote:
Hello,I have a database that records leaves taken by employees.Every
record has employee name,leavefrom(to record the starting date of
leave) & leaveupto( for the leave end date).My requirement is to find
out monthwise, the no of days of leave taken by an employee.The problem
comes when the end date falls in the subsequent month of start date.Ex:
say an employee Mr. X takes leave from 29-Oct-06 to 03-Nov-06.I need an
output like the following:

Emp Name Month Leaves taken
X Oct2006 3
X Nov2006 3

(for the above dates)

I have tried making two queries with a month criteria but can't get an
output like the one given above.Please help.
I might add another field to your table called LeaveProcessed. It'd be
a YesNo field, default False. When a leave is recorded, the employee
date from/to would be recorded. Later, you could process it...or at the
end of data entry.

Tnen run a query to select all records that are unprocessed. Something
like:
Select LeaveDays : MakeLeaveRec([EmpID], [Leavestart], LeaveEnd]) _
From LeaveTable WHere LeaveProcessed = False

This query calls a function called MakeLeaveRec and passes the requisite
info to it.

In your function, you parse out the days. You can get the 1st and last
days of the month (see DateSerial functions). Get the first of the
month. x = DateSerial(Year(Date),Month(date),1). Get the last day of
the month. y = DateAdd("m",1,x). Now you can check to see if there are
overlaps.

Now...write/append a record to another table that shows the breakouts.
Most of the times you'll get 1 rec as leaves will be in the same month.
For those that span multiple months you can calc/write them out. This
way you get one rec per month.

Now in your reports you'd select records from this table. Then update
the LeaveProcessed to true. You call a select statement that in reality
ends up as an append query.

Nov 4 '06 #2
thanks for your reply.But I would like to avoid the manual
intervention/calculation to segregate the record having spanned month
into two.Can we design a query/set of queries to break it up?

salad wrote:
P.Jaimal wrote:
Hello,I have a database that records leaves taken by employees.Every
record has employee name,leavefrom(to record the starting date of
leave) & leaveupto( for the leave end date).My requirement is to find
out monthwise, the no of days of leave taken by an employee.The problem
comes when the end date falls in the subsequent month of start date.Ex:
say an employee Mr. X takes leave from 29-Oct-06 to 03-Nov-06.I need an
output like the following:

Emp Name Month Leaves taken
X Oct2006 3
X Nov2006 3

(for the above dates)

I have tried making two queries with a month criteria but can't get an
output like the one given above.Please help.
I might add another field to your table called LeaveProcessed. It'd be
a YesNo field, default False. When a leave is recorded, the employee
date from/to would be recorded. Later, you could process it...or at the
end of data entry.

Tnen run a query to select all records that are unprocessed. Something
like:
Select LeaveDays : MakeLeaveRec([EmpID], [Leavestart], LeaveEnd]) _
From LeaveTable WHere LeaveProcessed = False

This query calls a function called MakeLeaveRec and passes the requisite
info to it.

In your function, you parse out the days. You can get the 1st and last
days of the month (see DateSerial functions). Get the first of the
month. x = DateSerial(Year(Date),Month(date),1). Get the last day of
the month. y = DateAdd("m",1,x). Now you can check to see if there are
overlaps.

Now...write/append a record to another table that shows the breakouts.
Most of the times you'll get 1 rec as leaves will be in the same month.
For those that span multiple months you can calc/write them out. This
way you get one rec per month.

Now in your reports you'd select records from this table. Then update
the LeaveProcessed to true. You call a select statement that in reality
ends up as an append query.
Nov 5 '06 #3
P.Jaimal wrote:
thanks for your reply.But I would like to avoid the manual
intervention/calculation to segregate the record having spanned month
into two.Can we design a query/set of queries to break it up?
I'm wondering why you just don't make a table that breaks them up when
the data is entered.

As far as I know, to select for one record and break it out to one or
more would be difficult in a select query. You maybe could checkout
NextRecord/MoveLayout/PrintRecord in help and present it in a report.
>
salad wrote:
>>P.Jaimal wrote:
>>>Hello,I have a database that records leaves taken by employees.Every
record has employee name,leavefrom(to record the starting date of
leave) & leaveupto( for the leave end date).My requirement is to find
out monthwise, the no of days of leave taken by an employee.The problem
comes when the end date falls in the subsequent month of start date.Ex:
say an employee Mr. X takes leave from 29-Oct-06 to 03-Nov-06.I need an
output like the following:

Emp Name Month Leaves taken
X Oct2006 3
X Nov2006 3

(for the above dates)

I have tried making two queries with a month criteria but can't get an
output like the one given above.Please help.

I might add another field to your table called LeaveProcessed. It'd be
a YesNo field, default False. When a leave is recorded, the employee
date from/to would be recorded. Later, you could process it...or at the
end of data entry.

Tnen run a query to select all records that are unprocessed. Something
like:
Select LeaveDays : MakeLeaveRec([EmpID], [Leavestart], LeaveEnd]) _
From LeaveTable WHere LeaveProcessed = False

This query calls a function called MakeLeaveRec and passes the requisite
info to it.

In your function, you parse out the days. You can get the 1st and last
days of the month (see DateSerial functions). Get the first of the
month. x = DateSerial(Year(Date),Month(date),1). Get the last day of
the month. y = DateAdd("m",1,x). Now you can check to see if there are
overlaps.

Now...write/append a record to another table that shows the breakouts.
Most of the times you'll get 1 rec as leaves will be in the same month.
For those that span multiple months you can calc/write them out. This
way you get one rec per month.

Now in your reports you'd select records from this table. Then update
the LeaveProcessed to true. You call a select statement that in reality
ends up as an append query.

Nov 5 '06 #4
Now it works!The table structure had to be modified as you
suggested.Thanks a lot.
salad wrote:
P.Jaimal wrote:
thanks for your reply.But I would like to avoid the manual
intervention/calculation to segregate the record having spanned month
into two.Can we design a query/set of queries to break it up?

I'm wondering why you just don't make a table that breaks them up when
the data is entered.

As far as I know, to select for one record and break it out to one or
more would be difficult in a select query. You maybe could checkout
NextRecord/MoveLayout/PrintRecord in help and present it in a report.

salad wrote:
>P.Jaimal wrote:

Hello,I have a database that records leaves taken by employees.Every
record has employee name,leavefrom(to record the starting date of
leave) & leaveupto( for the leave end date).My requirement is to find
out monthwise, the no of days of leave taken by an employee.The problem
comes when the end date falls in the subsequent month of start date.Ex:
say an employee Mr. X takes leave from 29-Oct-06 to 03-Nov-06.I need an
output like the following:

Emp Name Month Leaves taken
X Oct2006 3
X Nov2006 3

(for the above dates)

I have tried making two queries with a month criteria but can't get an
output like the one given above.Please help.
I might add another field to your table called LeaveProcessed. It'd be
a YesNo field, default False. When a leave is recorded, the employee
date from/to would be recorded. Later, you could process it...or at the
end of data entry.

Tnen run a query to select all records that are unprocessed. Something
like:
Select LeaveDays : MakeLeaveRec([EmpID], [Leavestart], LeaveEnd]) _
From LeaveTable WHere LeaveProcessed = False

This query calls a function called MakeLeaveRec and passes the requisite
info to it.

In your function, you parse out the days. You can get the 1st and last
days of the month (see DateSerial functions). Get the first of the
month. x = DateSerial(Year(Date),Month(date),1). Get the last day of
the month. y = DateAdd("m",1,x). Now you can check to see if there are
overlaps.

Now...write/append a record to another table that shows the breakouts.
Most of the times you'll get 1 rec as leaves will be in the same month.
For those that span multiple months you can calc/write them out. This
way you get one rec per month.

Now in your reports you'd select records from this table. Then update
the LeaveProcessed to true. You call a select statement that in reality
ends up as an append query.
Nov 6 '06 #5

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

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
2
by: Shaun | last post by:
Hi, I have a table called Bookings which has two important columns; Booking_Start_Time and Booking_End_Time. These columns are both of type DATETIME. Given any day how can I calculate how many...
4
by: Mark Reed | last post by:
Hi all, I have a query (query1) which shows scan date, scan time & operator. One scan = 1 record. What I want to do is create a report based on query 2 from query1 which shows all the scans AND...
6
by: Penguin | last post by:
At some long ago time Steve Jorgensen answered thus: Subject: Re: How can I round a time? Newsgroups: comp.databases.ms-access Date: 1998/12/11 Access represents a date internally as a double...
3
by: Ted Burhan | last post by:
Hi all, I'm trying to display a real-time data in one form or another (i.e. animation/graphic file, or just a text) in asp.net. The data for the images/text is retrieved from a SQL Server...
2
by: Rombolt | last post by:
Hi I have a MSSQL table with many time intervals stored as datetime. Each time interval is also assigned a numeric type that specifies what type of job was done during the time interval. I need to...
1
by: lenygold via DBMonster.com | last post by:
I found this query on older thread and i can not uderstand output interval pairs: How to find min and max values in date intervals: -------------------------------------------------- Input:...
9
by: Ross | last post by:
I'm a newbie at this, and have searched a lot but can't find something that seems appropriate for measuring a recurring elapsed time. Creating an object with: var mydate = new Date(); seems...
15
by: student4lifer | last post by:
Hello, I have 2 time fields dynamically generated in format "m/d/y H:m". Could someone show me a good function to calculate the time interval difference in minutes? I played with strtotime() but...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.