devxlogo

Date format

Date format

Question:
My application (RIS) converts a date in an integer to store it in a Database. Integer = x seconds after 1.1.1970 (for ex., 709444800). I want to make a SQL query that will reconvert this INT into a date format.

Answer:
The only way to do this as a SELECT statement is to embed the math in theSELECT clause and then CAST or otherwise convert the result to date format.

This would be quite unsightly as a query and wouldn’t lend itself well to use in multiple places. If your database supports user-definedfunctions, that would be the best solution. Alternatively, a storedprocedure or trigger could do the conversion for you.

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist