Added module to retun list of birthdays and anniversaries
This commit is contained in:
parent
47279f9282
commit
efe22e1c1a
53
finddates.py
Normal file
53
finddates.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import fredmssql
|
||||||
|
|
||||||
|
|
||||||
|
def get_birthdays(start, thru):
|
||||||
|
db = fredmssql.FredDB(DATABASE_USER, DATABASE_PASS, DATABASE_NAME)
|
||||||
|
s = (" SELECT e.EmpUID, e.LastName, e.FirstName, e.BirthDate "
|
||||||
|
" FROM Employee e "
|
||||||
|
"LEFT JOIN EmpCstFV c ON e.EmpUID = c.EmpUID AND c.CstID = 105 "
|
||||||
|
" WHERE e.CompanyID = 6 "
|
||||||
|
" AND e.TermDate IS NULL "
|
||||||
|
"AND DATEADD(year, %s - YEAR(e.BirthDate), e.BirthDate) "
|
||||||
|
" >= CONVERT(datetime, %s, 120) "
|
||||||
|
"AND DATEADD(year, %s - YEAR(e.BirthDate), e.BirthDate) "
|
||||||
|
" <= CONVERT(datetime, %s, 120)"
|
||||||
|
" AND CASE WHEN c.EmpGCstF1 = 0 THEN 0 ELSE 1 END = 1 "
|
||||||
|
"ORDER BY e.LastName, e.FirstName"
|
||||||
|
)
|
||||||
|
|
||||||
|
result = db.execute(s, (start.year,
|
||||||
|
start.strftime('%Y-%m-%d'),
|
||||||
|
thru.year,
|
||||||
|
thru.strftime('%Y-%m-%d')
|
||||||
|
))
|
||||||
|
db.close()
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def get_anniversary(start, thru):
|
||||||
|
db = fredmssql.FredDB(DATABASE_USER, DATABASE_PASS, DATABASE_NAME)
|
||||||
|
s = (" SELECT e.EmpUID, e.LastName, e.FirstName, e.HireDate "
|
||||||
|
" FROM Employee e "
|
||||||
|
"LEFT JOIN EmpCstFV c ON e.EmpUID = c.EmpUID AND c.CstID = 105 "
|
||||||
|
" WHERE e.CompanyID = 6 "
|
||||||
|
" AND e.TermDate IS NULL "
|
||||||
|
"AND DATEADD(year, %s - YEAR(e.HireDate), e.HireDate) "
|
||||||
|
" >= CONVERT(datetime, %s, 120) "
|
||||||
|
"AND DATEADD(year, %s - YEAR(e.HireDate), e.HireDate) "
|
||||||
|
" <= CONVERT(datetime, %s, 120)"
|
||||||
|
" AND CASE WHEN c.EmpGCstF1 = 0 THEN 0 ELSE 1 END = 1 "
|
||||||
|
"ORDER BY e.LastName, e.FirstName"
|
||||||
|
)
|
||||||
|
|
||||||
|
result = db.execute(s, (start.year,
|
||||||
|
start.strftime('%Y-%m-%d'),
|
||||||
|
thru.year,
|
||||||
|
thru.strftime('%Y-%m-%d')
|
||||||
|
))
|
||||||
|
db.close()
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
pass
|
Loading…
Reference in New Issue
Block a user