473,407 Members | 2,315 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,407 software developers and data experts.

Access: Convert Date Range to corresponding months

2
Dear Friends......I have the data like:-

Emp_ID Start_Date End_Date Pay_Due Pay_Drawn
===== ======== ======= ======= ========
101 07-APR-2008 31-JAN-2009 15000 12000
101 01-FEB-2009 20-MAR-2009 20000 17000
102 01-FEB-2008 15-APR-2009 10000 90000

Each employee can have multiple lines in the table. We have to calculate each employees salary difference (from pay_due to pay_drawn) between startate and

End_date calculation is based on the number of days in corresponding month and the differnece of pay_due and pay_drwan.

for example data is:-

Emp_ID Start_Date End_Date Pay_Due Pay_Drawn
===== ======== ======= ======= ========
101 07-APR-2008 31-JAN-2009 15000 12000
101 01-FEB-2009 20-MAR-2009 20000 17000

an employee can have multiple lines:
each line should be treated separately:

Note: salary is calculated on [differnece of pay_due and pay_drawb] no. of days in each month based on the start and end dates)

solution is required by the query if possible otherwise any procedure be acceptable.

Solution is required:-
1) select employees first row/line criteria is based on its Start and End data and then data is splited from start_date to end_date by month title
and Pay_due and Pay_Drawn is calculted according to the days in a month and days are based on Start and End Dates.

like---
Start_Date:07-APR-2008
End_Date: 31-JAN-2009
In above case data is formatted from emp_id = 101
Calculates no. days in each month

OUTPUT SHOULD BE LIKE THiS: (periods expand from start to end dates)
---------------------------
Month Name: April May-08 June-08 July-08 Aug-08 Sep-08 Oct-08 Nov-08 Dec-08 Jan-09
No. of days: 24 31 30 31 31 30 31 30 31 31


Then caluclate the Pay_Due and Pay_Drawn according to the days in a particular month.

Thanx

Experts Please help out.....
Apr 20 '10 #1
3 3005
NeoPa
32,556 Expert Mod 16PB
Calculating the number of days and the difference between [Pay_Due] & [Pay_Drawn] is relatively straightforward. For the expanding columns situation you would need two things :
  1. Data from somewhere that represents all the items you need to show.
    IE. You need some form of record source that includes all the months you intend to cover.
  2. To expand the columns you'd need a CrossTab type query. Otherwise columns in SQL must be predefined in the SQL itself.
I don't understand why, in such a scenario, the individual columns would need to be separated, but if they must be, then this is where you would need to start and get sorted out before going any further. To be honest, I have little to no experience with CrossTab queries, but I may be able to help with the basic data if you have further questions on it.
Apr 20 '10 #2
ogdcl
2
Thanks dear for ur timely response....

Ur righ, Calculating the number of days and the difference between [Pay_Due] & [Pay_Drawn] is relatively straightforward.

i want to present the data scanario first then the what is required from the data and lastly the solution is required (in the form of any query or procedure etc).

Data in the table is stored like this:

Emp_ID Start_Date End_Date Pay_Due Pay_Drawn
===== ======== ======= ======= ========
101 07-APR-2008 31-JAN-2009 15000 12000
101 01-FEB-2009 20-MAR-2009 20000 17000
102 01-FEB-2008 15-APR-2009 10000 90000

an employee can have multiple records:
in the above data shows the start and end periods in which employee is paid by pay_drawn and pay_due shows the due amount.
The requirement is:-
Now we have to organize the data in a new table by months column names and each month is based on the number of days in start_date and end_date and months also be calculated from start_date to end_date and finally the difference of pay_due and pay_drawn be calculated in each month..
e.g:
101 07-APR-2008 31-JAN-2009 15000 12000
months be calculated sepratly from april-08 to jan-09 and based on number of days present in the start and end dates. and each month have data (difference of pay_due and pay_drawn calculated on number of days in extracted months)..

present the basic data and how to extract the required information from the basic data.

I hope that i may try to give u the whole scanario for better understanding the problem......


Shah....
Apr 21 '10 #3
NeoPa
32,556 Expert Mod 16PB
Shah,

I'm not about to do it all for you. I thought I'd already pointed you in the direction you need to take. Any further questions or request for help would need to be framed within that context, or if that's not possible for some reason, then the reason needs to be explained. Personally, I'm pretty confident that what I've said is right, so over to you to make some progress.
Apr 21 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
1
by: Matt | last post by:
I would like to convert a couple informix stored procedures to SQL Server stored procedures. I have no idea how to accomplish this. Here is an example of one of the procedures I need to convert. ...
2
by: lpeterson | last post by:
I'm trying to calculate the number of months between dates that begin in 2003 and end in 2004(ex. 1/2/2003 - 7/2/2004). I need the total months in 2003 and in 2004 both of which should add up to...
1
by: Brian Jorgenson | last post by:
I am looking for a formula to put in my query to pull data based on the last 3 months. It starts with the current day and will go back 3 months. Here is my wrkflow language for example: ...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
4
by: JMCN | last post by:
object invalid or no longer set - confusion of the recordset in access 2003. i am currently converting from access 97 to access 2003. majority of the codes converted over perfectly fine, though...
14
by: awayne | last post by:
I am working with MS VB 6.5. I am putting together a MS Access (MS Access 2000) database for work to keep track of the projects and their status that we've done. I use MS Access to run a "Make-table...
1
by: ramaswamynanda | last post by:
Hello all, I have a timesheet details table . I am trying to run the following query against it. SELECT ., . FROM timesheetdetails WHERE Format(,'dd/mm/yyyy') between '01/01/2007' and...
2
by: wendy | last post by:
I have a table with projects that have a start date, an end date and total hours, for example: Project StartDate EndDate Hours Plumbing 3/16/07 ...
2
by: sixstringsk | last post by:
Can anyone here help me with this... I have a date code to display the date 7 days in the future— check it out here : http://hidefsounds.com/date.html The problem is that the day of the month...
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
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
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
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.