Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pay period date range

Status
Not open for further replies.

dandanearl

Technical User
Jan 16, 2013
8
US
I'm looking for some validation on my date range solution.
I'm running a sql query in crystal reports as a command that is looking at the performance of an employee during their pay period(bi-weekly). I'm using business objects to automate the creation/sending of the report in excel format every 15 days on the monday after the end of their pay period. In my sql I have a fixed date constraint of:
SQL:
(logdate BETWEEN dateadd(day, datediff(day, 0 ,getdate())-15, 0) and dateadd(day,datediff(day, 0 ,getdate())-2, 0))
The pay period always starts on Sunday at 12:00:00AM and ends on following Saturday 11:59:59PM. The report is generated on Monday -2 = Saturday and Monday - 15 = Previous Sunday to capture 14 day period.

Am I thinking this through correctly?
Thanks
 
Looks like the period ends on Saturday at 0000, so any hours worked on Saturday aren't included. Make the second datediff -1 instead of -2.

-----------
With business clients like mine, you'd be better off herding cats.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top