Extracting only date part of a date time column using JPA/Hibernate

I recently had a need where I had to get only the date portion from a column whose data type is “timestamp” (which is mapped using @TimeStamp annotation). After hours of investigation, I found a way to do that using standard jpa/hql queries and hence thought of documenting it in this post. MySQL has a simple “date() function” that would just give the date part from a date time expression. Microsoft SQL Server offers a couple of ways to achieve the same. Unfortunately, I couldn’t find any standard ways provided by jpa/hibernate to achieve this. Interestingly, the closest thing that can be considered as “standard” is the “cast function” which many databases seem to support. This prompted me to go for this solution because I felt this might be clean, as the syntax across different databases are pretty much similar. . . . → Read More: Extracting only date part of a date time column using JPA/Hibernate

Categories

A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.