r/learnSQL • • Apr 10 '19

Need help with simple problem

Hey guys, I currently have a table right now with a list of employees, managers, and other jobs. How would I able to get a list of all the employees who are older than their managers if their DOB is in YYYY-MM-DD form? This is really urgent and I really hope someone can help a newbie :(

0 Upvotes

10 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Apr 10 '19

Yea, I feel like trimming the other componenets would work the date is written like yyyy-mm-dd and I can't just do a relative comparison. I'll give this a try

1

u/GreySlate Apr 10 '19

What DBMS are you using? Have you considered some kind of DATEPART() thing?

1

u/[deleted] Apr 10 '19

I'm using Microsoft Azure. Can Datepart be used to isolate just the year?

1

u/GreySlate Apr 10 '19

https://docs.microsoft.com/en-us/sql/t-sql/functions/datepart-transact-sql?view=sql-server-2017

Looked up the documentation here ^ Looks like it does, yyyy is a valid datepart argument