I deal with this with another dev I work with. He loves working in SQL, and does basically everything there, business logic, formatting, etc. Bugs me to no end. In my opinion (and at least for the apps we work on) SQL is for handling data storage and retrieval, server code/client code is for presenting the data to the user and dealing with the user's interactions with that data.
This isn't limited to just SQL (or other DB engine) vs. your application code though. In instances where the server code is more of an API, handing data to a javascript heavy web application, the same thing applies. The API doesn't know what the UI might want to do with the data, the API's purpose should be to deliver raw data, and let the javascript/presentation code deal with formatting it in the required manner.
I'm sure there are exceptions to this, but that's the general rule I like to follow. Formatting is in the realm of presentation, not business logic or data-retrieval. Keep it there.
EDIT: I reread your question and I think I missed a subtle but crucial point. If you have a constructor or model or what-have-you that's expecting an input in a particular format, it might be wise to do that formatting/conversion in SQL to avoid the extra step of converting the data before you can use it. It will depend heavily on the problem trying to be solved though, and the specifics of where the data is coming from and where it's going to be used.