Why is datetime column being converted to a number in a query?

It’s a Perspective thing. Javascript doesn’t have a datetime datatype. At bottom, Javascript has numbers and strings, so Perspective has to coerce all data into one or the other on the way to the browser. Perspective components that manipulate dates know to convert back and forth on the front end. As @victordcq pointed out, the Perspective table will also do this if you configure the column to render as a date.