Pedals spin freely in cold conditions I recently bought a second hand Giant Upland SE and to be frank, it is my first bike with multiple gears. The bike functioned normally for the first day or two. I could use all the gears.  When the bike is stored indoors, the pedal and wheel work fine but once I take it out in the cold (anywhere from 0 to -30 degrees celsius), the pedals rotate freely and have no action on the wheel. Also I am not able use some gears on the rear wheel. Can anyone please help with an explanation and solution?
The pawls in your freehub are most likely getting stuck, causing them not to lock and transfer the force from the cassette to the wheel. In your case as the bike is new it is probably due to it being assembled with grease rather than a lighter oil, but the problem can also come with ageing. You will need to rebuild the freehub. This is not the easiest procedure and requires some specific tools (chain whip and freehub nut at least) so probably get your bike shop to do it.

The unusable gears on the back could be a number of things, rear derailleur limit screws, lack of cable tension, bent hanger/derailleur... If you are already taking it to a bike shop just ask them to fix it.

EDIT: Based on the additional information (-30 not 30  Celcius and secondhand), like others say the freehub is most likely frozen due to old grease and or water which has gotten inside the hub. Same advice still applies though, you will need to overhaul it and get new grease in there or just buy a new one.