It's a matter of style. More often than not, an en dash is used (without any spaces), but it depends on what style guide is followed.
From The Chicago Manual of Style (6.78):
The principal use of the en dash is to connect numbers and, less
often, words. With continuing numbers—such as dates, times, and page
numbers—it signifies up to and including (or through). For the sake of
parallel construction, the word to or through (or until), never the
en dash, should be used if the word from precedes the first element in
such a pair; similarly, and should be used if between precedes the
The years 1993–2000 were heady ones for the computer literate.
For source citations and indexing, see chapters 14–16.
In Genesis 6:13–21 we find God’s instructions to Noah.
Join us on Thursday, 11:30 a.m.–4:00 p.m., to celebrate the New Year.
I have blocked out December 2016–March 2017 to complete my manuscript.
Her articles appeared in Postwar Journal (3 November 1945–4 February 1946).
She was in college from 2012 to 2016 (not from 2012–16).
He usually naps between 11:30 a.m. and 1:30 p.m. (not between 11:30
Whatever style is used, it should be used consistently within the same text.
Note: I think your question actually used a hyphen, not an en dash.
Hyphen: -, en dash: –, em dash: —.