You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Spadez <ja...@hotmail.com> on 2013/03/19 18:04:52 UTC

Importing datetime

This is the datetime format SOLR requires as I understand it:

1995-12-31T23:59:59Z

When I try to store this as a datetime field in MySQL it says it isn't
valid. My question is, ideally I would want to keep a datetime in my
database so I can sort by date rather than just making it a varchar, so I
would store it like this:

1995-12-31 23:59:59 

Can import date in this format into SOLR from MySQL?

Thanks!



--
View this message in context: http://lucene.472066.n3.nabble.com/Importing-datetime-tp4049026.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Importing datetime

Posted by Andy Lester <an...@petdance.com>.
On Mar 19, 2013, at 12:04 PM, Spadez <ja...@hotmail.com> wrote:

> This is the datetime format SOLR requires as I understand it:
> 
> 1995-12-31T23:59:59Z
> 
> When I try to store this as a datetime field in MySQL it says it isn't
> valid. My question is, ideally I would want to keep a datetime in my
> database so I can sort by date rather than just making it a varchar, so I
> would store it like this:
> 
> 1995-12-31 23:59:59 
> 
> Can import date in this format into SOLR from MySQL?

Yes.  Don't change the storage type of your column in MySQL.  Changing to VARCHAR would be sad.

What you'll need to do is use a date formatting function in your SELECT out of the MySQL database to get the date into the format that MySQL likes.

See https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format 

xoa


--
Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance