They are largely interchangeable, with anoche being far more common, but noche pasada is more precise and formal, and it has more use in Spain than elsewhere.
Here is a breakdown of the night:
- Anoche - Last night, and is an abbreviated version of the also seen Ayer noche (yesterday's night). A literal meaning would be the events before midnight of the day before, but it has been extended by usage to cover the entire period between yesterday and today.
- Noche pasada - Last night, most literally the night most recently completed. This is the more literal and accurate term for the period between yesterday's dusk and today's dawn.
- Noche cerrada - Darkest night, literally meaning the period of the night when there is no light at all from the sun, but it is used to speak of very late at night; the wee-hours.
- Medianoche - Midnight and the time immediately around it
- Primera noche - The first night, as in the first night of some week-long event. But also it can refer to the earliest hours of the night, essentially the evening of some day.
- La última noche - The last night of something.
If you think about it, 'last night' is always the past in reference to the present, while 'the night before' could be in reference to any time, in the future 'the night before I die...' the present 'tonight is the night before my birthday' or the past 'the night before last I couldn't sleep a wink'