Foros de discusión

How to get distinct value based on year & month from date column using DQ

RAVI RAJAMANI, modificado hace 6 años.

How to get distinct value based on year & month from date column using DQ

Regular Member Mensajes: 123 Fecha de incorporación: 7/12/14 Mensajes recientes
Hi,

How to get distinct value based on year & month from date column(ex- Display date column) using Dynamic Query.

Regards,
Ravi
RAVI RAJAMANI, modificado hace 6 años.

RE: How to get distinct value based on year & month from date column using

Regular Member Mensajes: 123 Fecha de incorporación: 7/12/14 Mensajes recientes
Hi ,
Solution

DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(
				xyz.class, PortalClassLoaderUtil.getClassLoader());

		dynamicQuery
				.setProjection(ProjectionFactoryUtil.distinct((ProjectionFactoryUtil
						.sqlProjection(
								"year(displayDate) as year , month(displayDate) as month",
								new String[] { "year", "month" }, new Type[] {
										Type.INTEGER, Type.INTEGER }))));



Regards,
Ravi R