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

lil help for incoming bithday

Hi, i'm connected to a kronos db. I have 2 tbl.

tbl_Person
field_person_num
field_birthday_date

tbl_Employee
field_person_num
field_person_fullname
field_current_pay_Start(this is the current pay period start 05/10/16)
field_current_pay_End (this is the current pay period end, 05/10/22)
what i want to do is to have a report of my employee who have their
birhtday in the current pay period. the current pay period start on the
sunday and end's on saturday of each week. it auto update itself. or if
i could enter 2 date and have the employe who have their b-day in it
would be nice too.

date and b-day = yyyy/mm/dd (but i can change that in query)
i have a query with all those fields?
i dont know if i can do this in a query or do i have to do it in the
report. thx.

Nov 13 '05 #1
14 1343
No***********@hotmail.com wrote:
Hi, i'm connected to a kronos db. I have 2 tbl.

tbl_Person
field_person_num
field_birthday_date

tbl_Employee
field_person_num
field_person_fullname
field_current_pay_Start(this is the current pay period start 05/10/16)
field_current_pay_End (this is the current pay period end, 05/10/22)
what i want to do is to have a report of my employee who have their
birhtday in the current pay period. the current pay period start on the
sunday and end's on saturday of each week. it auto update itself. or if
i could enter 2 date and have the employe who have their b-day in it
would be nice too.

date and b-day = yyyy/mm/dd (but i can change that in query)
i have a query with all those fields?
i dont know if i can do this in a query or do i have to do it in the
report. thx.


Have you tried
SELECT (fields)
FROM (join)
WHERE
BD >= Start AND BD <= End
or
BD BETWEEN Start AND End
?
--
Smartin
Nov 13 '05 #2
yes i did, but the b-day of my employee r like 1956-12-01 ......any my
current pay period is 2005-10-10.... None of my enployee is born this
week (dont know if you understand), what cause me problem is the year.
I only need the month and the day. Its normal that when i enter my
formula like you wrote, it checks between 2005-10-10 and 2005-10-10. It
will check if i have an employee b-day between these 2 dates.

Is there a way to just look at the month and the day and forget about
the year?

Nov 13 '05 #3
I would suggest a public function to return a true/false for use in
your query as it is not as simple as stripping off the year and
comparing the values. For most of the year, this isn't a problem, but
if you have a payperiod that straddles the end of the year (e.g. start
date is 12/29 and end date is 01/06), you'd end up with a mess on your
hands. Here's the function I came up with. It isn't pretty, but it
does the trick. Perhaps someone has a better suggestion?

Public Function IsBDay(StartDate As Date, EndDate As Date, _
BDate As Date) As Boolean
Dim StartYr, EndYr As Integer
Dim StartMo As Integer
StartYr = Year(StartDate)
EndYr = Year(EndDate)
StartMo = Month(StartDate)
If StartDate > EndDate Then
MsgBox "Your start date must be earlier than your end date!"
Exit Function
End If
'Determine proper year to add to birth day and month
If StartYr = EndYr Then
'Year stays the same, so just use the year of the start date
BDate = CDate(StartYr & "/" & Month(BDate) & "/" & Day(BDate))
Else
'Payperiod straddles over the end of the year,
'so decide which year to use
If Month(BDate) = StartMo Then
'BD is just before the end of the year
'so use StartDate's year
BDate = CDate(StartYr & "/" & Month(BDate) & "/" & Day(BDate))
Else
'BD is just after the end of the year
'so use EndDate's year
BDate = CDate(EndYr & "/" & Month(BDate) & "/" & Day(BDate))
End If
End If
If BDate >= StartDate And BDate <= EndDate Then
IsBDay = True
Else
IsBDay = False
End If
End Function

Use the function in your query, feeding the startdate, enddate and
birthdate fields into the function's arguments.

HTH,

Jana

Nov 13 '05 #4
No***********@hotmail.com wrote:
yes i did, but the b-day of my employee r like 1956-12-01 ......any my
current pay period is 2005-10-10.... None of my enployee is born this
week (dont know if you understand), what cause me problem is the year.
I only need the month and the day. Its normal that when i enter my
formula like you wrote, it checks between 2005-10-10 and 2005-10-10. It
will check if i have an employee b-day between these 2 dates.

Is there a way to just look at the month and the day and forget about
the year?


Oops silly me (^:

A little Googling reveals this ugly and untested potential solution:

SELECT * FROM MyTable WHERE
DateSerial(Year(PayStart),Month(Birthday),Day(Birt hday)) BETWEEN
DateSerial(Year(PayStart),Month(PayStart),Day(PayS tart)) AND
DateSerial(Year(PayEnd),Month(PayEnd),Day(PayEnd))
;

--
Smartin
Nov 13 '05 #5
Smartin:

Appears that the solution you found ignores the year issue when pay
period straddles the end of the year. If Birthday is 06/01/02 and pay
start is 05/12/29 and pay end is 06/01/02, this would do the following:

Remove the BD year and replace it with 2005, changing BD to 05/01/02,
which is NOT between 05/12/29 and 06/01/06.

Otherwise, it works great when the year on the start & end dates are
the same :D

Jana

Nov 13 '05 #6
Jana wrote:
Smartin:

Appears that the solution you found ignores the year issue when pay
period straddles the end of the year. If Birthday is 06/01/02 and pay
start is 05/12/29 and pay end is 06/01/02, this would do the following:

Remove the BD year and replace it with 2005, changing BD to 05/01/02,
which is NOT between 05/12/29 and 06/01/06.

Otherwise, it works great when the year on the start & end dates are
the same :D

Jana


Right you are Jana. This should take care of the "year-end bug":

SELECT * FROM MyTable WHERE
(
DateSerial(Year(PayStart),Month(Birthday),Day(Birt hday)) BETWEEN
DateSerial(Year(PayStart),Month(PayStart),Day(PayS tart)) AND
DateSerial(Year(PayEnd),Month(PayEnd),Day(PayEnd))
)
OR
(
DateSerial(Year(PayEnd),Month(Birthday),Day(Birthd ay)) BETWEEN
DateSerial(Year(PayStart),Month(PayStart),Day(PayS tart)) AND
DateSerial(Year(PayEnd),Month(PayEnd),Day(PayEnd))
)
;

PS I like your VB solution too!
--
Smartin
Nov 13 '05 #7
Smartin wrote:
PS I like your VB solution too!


Here's another VB solution for your entertainment.

Public Function boolBirthdayThisWorkWeek(dtBirth As Date, dtTimeTicket
As Date) As Boolean
Dim dtSundayStarting As Date
Dim dtSaturdayEnding As Date
Dim intAgeSaturday As Integer
Dim intAgeSunday As Integer

dtSundayStarting = DateAdd("d", 1 - WeekDay(dtTimeTicket),
dtTimeTicket)
dtSaturdayEnding = DateAdd("d", 6, dtSundayStarting)
intAgeSaturday = Int(Format(dtSaturdayEnding, "yyyy.mmdd") -
Format(dtBirth, "yyyy.mmdd"))
intAgeSunday = Int(Format(dtSundayStarting, "yyyy.mmdd") -
Format(dtBirth, "yyyy.mmdd"))
boolBirthdayThisWorkWeek = (intAgeSunday <> intAgeSaturday) Or
(Format(dtSundayStarting, "\.mmdd") = Format(dtBirth, "\.mmdd"))
End Function

James A. Fortune

Nov 13 '05 #8
ji********@compumarc.com wrote:
Smartin wrote:
PS I like your VB solution too!

Here's another VB solution for your entertainment.

Public Function boolBirthdayThisWorkWeek(dtBirth As Date, dtTimeTicket
As Date) As Boolean
Dim dtSundayStarting As Date
Dim dtSaturdayEnding As Date
Dim intAgeSaturday As Integer
Dim intAgeSunday As Integer

dtSundayStarting = DateAdd("d", 1 - WeekDay(dtTimeTicket),
dtTimeTicket)
dtSaturdayEnding = DateAdd("d", 6, dtSundayStarting)
intAgeSaturday = Int(Format(dtSaturdayEnding, "yyyy.mmdd") -
Format(dtBirth, "yyyy.mmdd"))
intAgeSunday = Int(Format(dtSundayStarting, "yyyy.mmdd") -
Format(dtBirth, "yyyy.mmdd"))
boolBirthdayThisWorkWeek = (intAgeSunday <> intAgeSaturday) Or
(Format(dtSundayStarting, "\.mmdd") = Format(dtBirth, "\.mmdd"))
End Function

James A. Fortune


I'm not clear on what should be passed for dtTimeTicket?

When I evaluate this function against an arbitrary DOB and any fixed
dtTimeTicket, it only returns true for dtTimeTicket = the last 7 days of
the year.
--
Smartin
Nov 13 '05 #9
Smartin wrote:
ji********@compumarc.com wrote:
Smartin wrote:
PS I like your VB solution too!

Here's another VB solution for your entertainment.

Public Function boolBirthdayThisWorkWeek(dtBirth As Date, dtTimeTicket
As Date) As Boolean
Dim dtSundayStarting As Date
Dim dtSaturdayEnding As Date
Dim intAgeSaturday As Integer
Dim intAgeSunday As Integer

dtSundayStarting = DateAdd("d", 1 - WeekDay(dtTimeTicket),
dtTimeTicket)
dtSaturdayEnding = DateAdd("d", 6, dtSundayStarting)
intAgeSaturday = Int(Format(dtSaturdayEnding, "yyyy.mmdd") -
Format(dtBirth, "yyyy.mmdd"))
intAgeSunday = Int(Format(dtSundayStarting, "yyyy.mmdd") -
Format(dtBirth, "yyyy.mmdd"))
boolBirthdayThisWorkWeek = (intAgeSunday <> intAgeSaturday) Or
(Format(dtSundayStarting, "\.mmdd") = Format(dtBirth, "\.mmdd"))
End Function

James A. Fortune


I'm not clear on what should be passed for dtTimeTicket?

When I evaluate this function against an arbitrary DOB and any fixed
dtTimeTicket, it only returns true for dtTimeTicket = the last 7 days of
the year.
--
Smartin


I envisioned dtTimeTicket to be any date during the work week, usually
the same as Date(). That way someone entering a time ticket for an
employee can be shown the information. The function calculates the
start and end of the work week based on that date. I tested this
function enough to be reasonably sure of its accuracy. Let me know if
you still have problems with it after supplying a different date for
dtTimeTicket. Perhaps the CDate function or #'s are required.

James A. Fortune

Nov 13 '05 #10
hehehe, u lost me.

i'm a bit confuse about the DateSerial function and there is not a lot
on it in the help file.

can any1 help me translation it.

i'll give it a try for the moment.

thx

Nov 13 '05 #11
No***********@hotmail.com wrote:
i'm a bit confuse about the DateSerial function and there is not a lot
on it in the help file.


Douglas Steele straightened me out on this one:

http://groups.google.com/group/comp....3acc8e2?hl=en&

In programming, expanding the solution to a specific problem to be able
to handle more general situations is known as abstraction. In general,
extra care has to be taken when doing in this direction.

James A. Fortune

Nov 13 '05 #12
Everyone:

Just goes to prove the old addage that there's more than one way to
skin a cat...

Smartin, I must admit that I never thought of adding in the OR
part...LOL

Hope that the OP found something that works for them...

Jana

Nov 13 '05 #13
No***********@hotmail.com wrote:
hehehe, u lost me.

i'm a bit confuse about the DateSerial function and there is not a lot
on it in the help file.

can any1 help me translation it.

i'll give it a try for the moment.

thx


I changed this to a SQL statement using the same table and field names
as Smartin for ease of comparison.

SELECT Int(Format(PayEnd, 'yyyy.mmdd') - Format(Birthday, 'yyyy.mmdd'))
AS AgeSaturday, Int(Format(PayStart, 'yyyy.mmdd') - Format(Birthday,
'yyyy.mmdd')) AS AgeSunday, ([AgeSunday] <> [AgeSaturday]) Or
(Format(PayStart, "\.mmdd") = Format(Birthday, "\.mmdd")) As
BirthdayThisWorkWeek FROM MyTable;

You can also substitute and use the less didactic:

SELECT (Int(Format(PayStart, 'yyyy.mmdd') - Format(Birthday,
'yyyy.mmdd')) <> Int(Format(PayEnd, 'yyyy.mmdd') - Format(Birthday,
'yyyy.mmdd'))) Or (Format(PayStart, "\.mmdd") = Format(Birthday,
"\.mmdd")) As BirthdayThisWorkWeek FROM MyTable;

I hope this is clearer,

James A. Fortune

Nov 13 '05 #14
yes a lot, thx , i'll work my way out with it.

Nov 13 '05 #15

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

Similar topics

5
by: simonc | last post by:
I've been programming in assembler and C/C++ for a number of years, but I'm only just starting down the road of PHP & MYSQL. I have a couple of questions: (1) Before I start writing my own...
2
by: Mike Verdone | last post by:
Hello all, I'm trying to implement a PHP program that can handle streaming HTTP data through Apache. I need to somehow get access to the incoming data of the HTTP request as it arrives (i.e. I...
1
by: Sveta | last post by:
Hello,all! I am new with J2ME. I have Nokia 3100 and 3205, both are MIDP.10. I need that application, like chat, will be started when SMS message is received. I used "Nokia-SMS-Handler-n" in...
2
by: Bob | last post by:
Hi Everybody A tough one!!! Is there any way that incoming eMails (MailItems) into Ms Outlook can be used to automatically create records in a ms Access table or sub table. Smiley Bob
7
by: Adam Clauss | last post by:
I am trying to work-around a firewall which limits me to only being able to accept inbound connections on port 80. Unfortunately, I need to two different applications to be able to accept...
4
by: sracherla | last post by:
I am trying to write a simple windows service that accepts an incoming request; receives a string input and sends a string output. I need this connection to stay alive until the client closes it....
5
by: Jens | last post by:
Hello, I have been looking for some C-code which listens on a user-defined port for incoming data traffic. When data is received, the data is written to a file. I found some C-code (server)...
1
subashini Thiyagarajan
by: subashini Thiyagarajan | last post by:
hi, I don't know is this the right forum Please can anyone help me i need to reduce the incoming telephone ring volume in the Panasonic set not mobile set normal phone set.their is no physical...
2
by: =?Utf-8?B?RGFuY2Vy?= | last post by:
Hi, I was attempting to check my new incoming emails through Outlook Express (I have Windows 98, 2nd Edition). My computer seemed to be having a problem accessing and opening the emails, and the...
0
by: rahulsengar | last post by:
Hey how can i lauch my application on incoming call notification in windows mobile . hey can u please help me how to launch my application automatically when an incoming call occurs. Is there any...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.