Barack Obama served for at least two years in office.
Barack Obama . He previously served in the U.S. Senate representing Illinois from 2005 to 2008 , and in the Illinois State Senate from 1997 to 2004 . During his first two years in office , Obama signed many landmark bills . Barack Obama served as the 44th President of the United States from 2009 to 2017 .