Slavery wasn’t outlawed (by Presidential decree) until January 1, 1863. Thus, 2 years, 4 months.
Then only in those areas of the United States in active rebellion against the United States. It did not apply in 4 states and the District of Columbia. Nor did it apply in large areas controlled by the Union Army such as Northern Tennessee or New Orleans LA, or Tidewater Virginia.