How do I compare hire date to MS SQL system date?

I have a MS SQl query that I want to know date hired for the last 30 days when comparing to MS SQL system date.  For example:
select
A.COMPANY as "Company"
,A.EMPLOYEE as "Employee"
, A.FIRST_NAME as "First Name"
, A.MIDDLE_NAME as "Middle Name"
, A.LAST_NAME  as "Last Name"
, A.SUPERVISOR as "Supervisor"
, A.EMP_STATUS as "Employee Status"
, A.DATE_HIRED as "Date Hired"
, A.ADJ_HIRE_DATE as "Adj Hire Date"
, A.TERM_DATE as "Term Date"
, SPR.FIRST_NAME "Supervisor First Name"
, SPR.MIDDLE_NAME as "Supervisor Middle Name"
, SPR.LAST_NAME as "Supervisor Last Name"
, SPR.EMAIL_ADDRESS as "Supervisor Email"
FROM EMPLOYEE A
LEFT JOIN HRSUPER HRS
ON A.SUPERVISOR = HRS.CODE
AND A.COMPANY = HRS.COMPANY
LEFT JOIN EMPLOYEE SPR
ON SPR.COMPANY = HRS.COMPANY
AND SPR.EMPLOYEE = HRS.EMPLOYEE
WHERE A.SUPERVISOR >='1000-10000'
AND SPR.EMAIL_ADDRESS > '   '
AND A.DATE_HIRED = GETDATE()-30

I use GETDATE()-30 and no records are returned.  I know there are records there, though.


garyjgsAsked:
Who is Participating?
 
sridharthirunagariConnect With a Mentor Commented:
select
A.COMPANY as "Company"
,A.EMPLOYEE as "Employee"
, A.FIRST_NAME as "First Name"
, A.MIDDLE_NAME as "Middle Name"
, A.LAST_NAME  as "Last Name"
, A.SUPERVISOR as "Supervisor"
, A.EMP_STATUS as "Employee Status"
, A.DATE_HIRED as "Date Hired"
, A.ADJ_HIRE_DATE as "Adj Hire Date"
, A.TERM_DATE as "Term Date"
, SPR.FIRST_NAME "Supervisor First Name"
, SPR.MIDDLE_NAME as "Supervisor Middle Name"
, SPR.LAST_NAME as "Supervisor Last Name"
, SPR.EMAIL_ADDRESS as "Supervisor Email"
FROM EMPLOYEE A
LEFT JOIN HRSUPER HRS
ON A.SUPERVISOR = HRS.CODE
AND A.COMPANY = HRS.COMPANY
LEFT JOIN EMPLOYEE SPR
ON SPR.COMPANY = HRS.COMPANY
AND SPR.EMPLOYEE = HRS.EMPLOYEE
WHERE A.SUPERVISOR >='1000-10000'
AND SPR.EMAIL_ADDRESS > '   '
AND A.DATE_HIRED >= GETDATE()-30

try this..
0
 
LowfatspreadCommented:
and a.datehired between convert(datetime, convert(char(8),dateadd(d,-30,getdate()),112)) and getdate()
0
 
garyjgsAuthor Commented:
thanks...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.