Try: select IF(sub_cat_id=2002, DATE_FORMAT(ad_post_date, '%Y-%m-%dT00:00:00Z/DAY'), null) as 'ad_sort_field' from tcuser.ad_details where <SOME_CONDiTION>
Ephraim Ofir -----Original Message----- From: Pawan Darira [mailto:pawan.dar...@gmail.com] Sent: Tuesday, October 26, 2010 1:29 PM To: solr-user@lucene.apache.org Subject: Re: How to index on basis of a condition? My Sql is select IF(sub_cat_id=2002, ad_post_date, null) as 'ad_sort_field' from tcuser.ad_details where <SOME_CONDiTION> +---------------+ | ad_sort_field | +---------------+ | 2010-05-30 | | 2010-05-02 | | 2010-10-07 | | NULL | | 2010-10-15 | | NULL | +--------------------+ Thanks Pawan On Tue, Oct 26, 2010 at 4:36 PM, Gora Mohanty <g...@mimirtech.com> wrote: > On Tue, Oct 26, 2010 at 3:56 PM, Pawan Darira <pawan.dar...@gmail.com> > wrote: > > I am using mysql database, and, field type is "date" > [...] > > Could you show us the exact SELECT statement, and some example > values returned by running the SELECT directly at a mysql console? > > Regards, > Gora > -- Thanks, Pawan Darira