There are two ways of looking at how long you spend doing something:
(1) You can ask how long it took to get it done, specifying the time period within which the task was completed. In this situation use a Perfective verb and the preposition за + Accusative.
(2) You can ask how much time was spent being engaged in the activity, without specifying whether a particular amount of work got done within that period. In this situation use an Imperfective verb and Accusative without preposition. Note the translation 'spent' for this construction in the last example below.
Pf. — За скћлько врљмени вІ написђли іту статьє? "How long did it take you to write that article?"
  — (Ї её написђла) за недљлю. "(I wrote it in) a week."
 
Impf. — Кђк дћлго вІ тђм жќли? "How long did you live there?"
  — (Ї тђм жилђ) недљлю. "(I lived there) a week."
  — (Ї тђм жилђ) вљсь гћд. "(I lived there) the whole year."
 
Pf. — Ї купќла одљжду за двђ часђ. "I bought my clothes in two hours."
Impf. — Ї покупђла одљжду двђ часђ. "I spent two hours shopping for clothes."