Re: How to handle string as java date type
Hi Dharam, The JSONFormatter uses Jackson under the covers. It would understand the ISO date standard and under the covers covert the field into a date. You must just be aware that as soon as you add a time component, it does not read that correctly (it parses dates, but not date time unless told otherwise). If you are certain you will never have a time component, your below described method would work. If you suspect you might receive a time component, I'd advise to use the Long representation. --Udo On 5/11/17 23:07, Thacker, Dharam wrote: Wow! Somehow I could make it work due to ISO date format followed across all data sources [-MM-DD]. In this case it works naturally due to lexicographic comparison of string fields. I can simply say now, select e.x,e.y,e.z from /Event e where e.legalDate > ‘2018-09-22’ At least Equals/Greater Than/Less Than works with ISO date format J Regards, Dharam *From:*Thacker, Dharam *Sent:* Thursday, May 11, 2017 8:57 PM *To:* user@geode.apache.org *Subject:* Re: How to handle string as java date type Hi Udo, Thanks for the update! Apologies for typo error in below query while writing. I tried correct one though in pulse. Long fields work for me but it requires some extra efforts as usually golden copy json store contains those fields as date string format but while uploading it to cache we have to apply data xformation to parse and convert json data. It would be great to see enhanced function support for such use cases ! Regards, Dharam Sent with BlackBerry Work (www.blackberry.com <http://www.blackberry.com>) *From: *Udo Kohlmeyer <u...@apache.org <mailto:u...@apache.org>> *Sent: *May 11, 2017 8:41 PM *To: *user@geode.apache.org <mailto:user@geode.apache.org> *Subject: *Re: How to handle string as java date type Hi Dharam, As Gang Yan indicated, comparing date entries using longs is far simpler than using Date strings. Also, have you noticed that you have 2 "from /Event e" clauses in your query. There is an ongoing discussion about a ways how to better handle unstructured data and how to describe the data fields. --Udo On 5/11/17 07:50, Gang Yan wrote: If you convert it to long, do not need to_date for the long field again. Thacker, Dharam <dharam.thac...@jpmorgan.com <mailto:dharam.thac...@jpmorgan.com>>于2017年5月11日 周四下午10:48写道: Ok even if I convert it long format, how I can use that in compare expression Assuming data as below, {"id":"5","eventId":"Event4","intField":400,"currentDate": 1471254472000,"legalDate": 1471254472000} select e from /Event e where to_date(e.currentDate,'/MM/dd') > to_date(‘2018/02/20’,’/MM/dd’) from /Event e Query is invalid due to error - Syntax error in query- expecting StringLiteral, found 'e' Regards, Dharam *From:*Gang Yan [mailto:g...@pivotal.io <mailto:g...@pivotal.io>] *Sent:* Thursday, May 11, 2017 8:11 PM *To:* user@geode.apache.org <mailto:user@geode.apache.org> *Subject:* Re: How to handle string as java date type hi Dharam maybe you can try to_date. but for reason of performance, I think that you can choose a long to represent a date value instead of a string. Thanks and regards Gang Yan(闫钢) Sr. Solution Architect Customer Success, Pivotal Great China Mobile:+86 13636347460 g...@pivotal.io <mailto:g...@pivotal.io> 2017-05-11 21:43 GMT+08:00 Thacker, Dharam <dharam.thac...@jpmorgan.com <mailto:dharam.thac...@jpmorgan.com>>: Hi Team, Is there any good way to play with DateType if I have PdxInstance data having date string with type [java.lang.String]? *_Example:_* "duedates": { "legalDate": "2022-04-19", "currentDate": "2022-04-19", } My goal is to get results based on date comparison, select i from /Event i where i.duedates.legalDate > ‘2022-04-15’ Thanks & Regards, Dharam This message is confidential and subject to terms at: http://www.jpmorgan.com/emaildisclaimer <http://www.jpmorgan.com/emaildisclaimer> including on confidentiality, legal privilege, viruses and monitoring of electronic messages. If you are not the intended recipient, please delete this message and notify the sender immediately. Any unauthorized use is strictly prohibited. This message is confidential and subject to terms at: http://www.jpmorgan.com/emaildisclaimer
RE: How to handle string as java date type
Wow! Somehow I could make it work due to ISO date format followed across all data sources [-MM-DD]. In this case it works naturally due to lexicographic comparison of string fields. I can simply say now, select e.x,e.y,e.z from /Event e where e.legalDate > ‘2018-09-22’ At least Equals/Greater Than/Less Than works with ISO date format :) Regards, Dharam From: Thacker, Dharam Sent: Thursday, May 11, 2017 8:57 PM To: user@geode.apache.org Subject: Re: How to handle string as java date type Hi Udo, Thanks for the update! Apologies for typo error in below query while writing. I tried correct one though in pulse. Long fields work for me but it requires some extra efforts as usually golden copy json store contains those fields as date string format but while uploading it to cache we have to apply data xformation to parse and convert json data. It would be great to see enhanced function support for such use cases ! Regards, Dharam Sent with BlackBerry Work (www.blackberry.com<http://www.blackberry.com>) From: Udo Kohlmeyer <u...@apache.org<mailto:u...@apache.org>> Sent: May 11, 2017 8:41 PM To: user@geode.apache.org<mailto:user@geode.apache.org> Subject: Re: How to handle string as java date type Hi Dharam, As Gang Yan indicated, comparing date entries using longs is far simpler than using Date strings. Also, have you noticed that you have 2 "from /Event e" clauses in your query. There is an ongoing discussion about a ways how to better handle unstructured data and how to describe the data fields. --Udo On 5/11/17 07:50, Gang Yan wrote: If you convert it to long, do not need to_date for the long field again. Thacker, Dharam <dharam.thac...@jpmorgan.com<mailto:dharam.thac...@jpmorgan.com>>于2017年5月11日 周四下午10:48写道: Ok even if I convert it long format, how I can use that in compare expression Assuming data as below, {"id":"5","eventId":"Event4","intField":400,"currentDate": 1471254472000,"legalDate": 1471254472000} select e from /Event e where to_date(e.currentDate,'/MM/dd') > to_date(‘2018/02/20’,’/MM/dd’) from /Event e Query is invalid due to error - Syntax error in query- expecting StringLiteral, found 'e' Regards, Dharam From: Gang Yan [mailto:g...@pivotal.io<mailto:g...@pivotal.io>] Sent: Thursday, May 11, 2017 8:11 PM To: user@geode.apache.org<mailto:user@geode.apache.org> Subject: Re: How to handle string as java date type hi Dharam maybe you can try to_date. but for reason of performance, I think that you can choose a long to represent a date value instead of a string. Thanks and regards Gang Yan(闫钢) Sr. Solution Architect Customer Success, Pivotal Great China Mobile:+86 13636347460 g...@pivotal.io<mailto:g...@pivotal.io> 2017-05-11 21:43 GMT+08:00 Thacker, Dharam <dharam.thac...@jpmorgan.com<mailto:dharam.thac...@jpmorgan.com>>: Hi Team, Is there any good way to play with DateType if I have PdxInstance data having date string with type [java.lang.String]? Example: "duedates": { "legalDate": "2022-04-19", "currentDate": "2022-04-19", } My goal is to get results based on date comparison, select i from /Event i where i.duedates.legalDate > ‘2022-04-15’ Thanks & Regards, Dharam This message is confidential and subject to terms at: http://www.jpmorgan.com/emaildisclaimer<http://www.jpmorgan.com/emaildisclaimer> including on confidentiality, legal privilege, viruses and monitoring of electronic messages. If you are not the intended recipient, please delete this message and notify the sender immediately. Any unauthorized use is strictly prohibited. This message is confidential and subject to terms at: http://www.jpmorgan.com/emaildisclaimer<http://www.jpmorgan.com/emaildisclaimer> including on confidentiality, legal privilege, viruses and monitoring of electronic messages. If you are not the intended recipient, please delete this message and notify the sender immediately. Any unauthorized use is strictly prohibited. -- null This message is confidential and subject to terms at: http://www.jpmorgan.com/emaildisclaimer including on confidentiality, legal privilege, viruses and monitoring of electronic messages. If you are not the intended recipient, please delete this message and notify the sender immediately. Any unauthorized use is strictly prohibited.
Re: How to handle string as java date type
Hi Udo, Thanks for the update! Apologies for typo error in below query while writing. I tried correct one though in pulse. Long fields work for me but it requires some extra efforts as usually golden copy json store contains those fields as date string format but while uploading it to cache we have to apply data xformation to parse and convert json data. It would be great to see enhanced function support for such use cases ! Regards, Dharam Sent with BlackBerry Work (www.blackberry.com) From: Udo Kohlmeyer <u...@apache.org> Sent: May 11, 2017 8:41 PM To: user@geode.apache.org Subject: Re: How to handle string as java date type Hi Dharam, As Gang Yan indicated, comparing date entries using longs is far simpler than using Date strings. Also, have you noticed that you have 2 "from /Event e" clauses in your query. There is an ongoing discussion about a ways how to better handle unstructured data and how to describe the data fields. --Udo On 5/11/17 07:50, Gang Yan wrote: If you convert it to long, do not need to_date for the long field again. Thacker, Dharam <dharam.thac...@jpmorgan.com<mailto:dharam.thac...@jpmorgan.com>>于2017年5月11日 周四下午10:48写道: Ok even if I convert it long format, how I can use that in compare expression Assuming data as below, {"id":"5","eventId":"Event4","intField":400,"currentDate": 1471254472000,"legalDate": 1471254472000} select e from /Event e where to_date(e.currentDate,'/MM/dd') > to_date(‘2018/02/20’,’/MM/dd’) from /Event e Query is invalid due to error - Syntax error in query- expecting StringLiteral, found 'e' Regards, Dharam From: Gang Yan [mailto:g...@pivotal.io<mailto:g...@pivotal.io>] Sent: Thursday, May 11, 2017 8:11 PM To: user@geode.apache.org<mailto:user@geode.apache.org> Subject: Re: How to handle string as java date type hi Dharam maybe you can try to_date. but for reason of performance, I think that you can choose a long to represent a date value instead of a string. Thanks and regards Gang Yan(闫钢) Sr. Solution Architect Customer Success, Pivotal Great China Mobile:+86 13636347460 g...@pivotal.io<mailto:g...@pivotal.io> 2017-05-11 21:43 GMT+08:00 Thacker, Dharam <dharam.thac...@jpmorgan.com<mailto:dharam.thac...@jpmorgan.com>>: Hi Team, Is there any good way to play with DateType if I have PdxInstance data having date string with type [java.lang.String]? Example: "duedates": { "legalDate": "2022-04-19", "currentDate": "2022-04-19", } My goal is to get results based on date comparison, select i from /Event i where i.duedates.legalDate > ‘2022-04-15’ Thanks & Regards, Dharam This message is confidential and subject to terms at: http://www.jpmorgan.com/emaildisclaimer<http://www.jpmorgan.com/emaildisclaimer> including on confidentiality, legal privilege, viruses and monitoring of electronic messages. If you are not the intended recipient, please delete this message and notify the sender immediately. Any unauthorized use is strictly prohibited. This message is confidential and subject to terms at: http://www.jpmorgan.com/emaildisclaimer<http://www.jpmorgan.com/emaildisclaimer> including on confidentiality, legal privilege, viruses and monitoring of electronic messages. If you are not the intended recipient, please delete this message and notify the sender immediately. Any unauthorized use is strictly prohibited. -- null This message is confidential and subject to terms at: http://www.jpmorgan.com/emaildisclaimer including on confidentiality, legal privilege, viruses and monitoring of electronic messages. If you are not the intended recipient, please delete this message and notify the sender immediately. Any unauthorized use is strictly prohibited.
Re: How to handle string as java date type
Hi Dharam, As Gang Yan indicated, comparing date entries using longs is far simpler than using Date strings. Also, have you noticed that you have 2 "from /Event e" clauses in your query. There is an ongoing discussion about a ways how to better handle unstructured data and how to describe the data fields. --Udo On 5/11/17 07:50, Gang Yan wrote: If you convert it to long, do not need to_date for the long field again. Thacker, Dharam <dharam.thac...@jpmorgan.com <mailto:dharam.thac...@jpmorgan.com>>于2017年5月11日 周四下午10:48写道: Ok even if I convert it long format, how I can use that in compare expression Assuming data as below, {"id":"5","eventId":"Event4","intField":400,"currentDate": 1471254472000,"legalDate": 1471254472000} select e from /Event e where to_date(e.currentDate,'/MM/dd') > to_date(‘2018/02/20’,’/MM/dd’) from /Event e Query is invalid due to error - Syntax error in query- expecting StringLiteral, found 'e' Regards, Dharam *From:*Gang Yan [mailto:g...@pivotal.io <mailto:g...@pivotal.io>] *Sent:* Thursday, May 11, 2017 8:11 PM *To:* user@geode.apache.org <mailto:user@geode.apache.org> *Subject:* Re: How to handle string as java date type hi Dharam maybe you can try to_date. but for reason of performance, I think that you can choose a long to represent a date value instead of a string. Thanks and regards Gang Yan(闫钢) Sr. Solution Architect Customer Success, Pivotal Great China Mobile:+86 13636347460 g...@pivotal.io <mailto:g...@pivotal.io> 2017-05-11 21:43 GMT+08:00 Thacker, Dharam <dharam.thac...@jpmorgan.com <mailto:dharam.thac...@jpmorgan.com>>: Hi Team, Is there any good way to play with DateType if I have PdxInstance data having date string with type [java.lang.String]? *_Example:_* "duedates": { "legalDate": "2022-04-19", "currentDate": "2022-04-19", } My goal is to get results based on date comparison, select i from /Event i where i.duedates.legalDate > ‘2022-04-15’ Thanks & Regards, Dharam This message is confidential and subject to terms at: http://www.jpmorgan.com/emaildisclaimer <http://www.jpmorgan.com/emaildisclaimer> including on confidentiality, legal privilege, viruses and monitoring of electronic messages. If you are not the intended recipient, please delete this message and notify the sender immediately. Any unauthorized use is strictly prohibited. This message is confidential and subject to terms at: http://www.jpmorgan.com/emaildisclaimer <http://www.jpmorgan.com/emaildisclaimer> including on confidentiality, legal privilege, viruses and monitoring of electronic messages. If you are not the intended recipient, please delete this message and notify the sender immediately. Any unauthorized use is strictly prohibited. -- null
Re: How to handle string as java date type
If you convert it to long, do not need to_date for the long field again. Thacker, Dharam <dharam.thac...@jpmorgan.com>于2017年5月11日 周四下午10:48写道: > Ok even if I convert it long format, how I can use that in compare > expression > > > > Assuming data as below, > > {"id":"5","eventId":"Event4","intField":400,"currentDate": > 1471254472000,"legalDate": 1471254472000} > > > > select e from /Event e where to_date(e.currentDate,'/MM/dd') > > to_date(‘2018/02/20’,’/MM/dd’) from /Event e > > > > Query is invalid due to error - Syntax error in query- expecting > StringLiteral, found 'e' > > > > Regards, > > Dharam > > > > *From:* Gang Yan [mailto:g...@pivotal.io] > *Sent:* Thursday, May 11, 2017 8:11 PM > *To:* user@geode.apache.org > *Subject:* Re: How to handle string as java date type > > > > hi Dharam > > > > maybe you can try to_date. > > > > but for reason of performance, I think that you can choose a long to > represent a date value instead of a string. > > > > > Thanks and regards > > > > Gang Yan(闫钢) > > Sr. Solution Architect > > Customer Success, Pivotal Great China > > Mobile:+86 13636347460 > > g...@pivotal.io > > > > 2017-05-11 21:43 GMT+08:00 Thacker, Dharam <dharam.thac...@jpmorgan.com>: > > Hi Team, > > > > Is there any good way to play with DateType if I have PdxInstance data > having date string with type [java.lang.String]? > > > > *Example:* > > "duedates": { > > "legalDate": "2022-04-19", > > "currentDate": "2022-04-19", > > } > > > > My goal is to get results based on date comparison, > > > > select i from /Event i where i.duedates.legalDate > ‘2022-04-15’ > > > > Thanks & Regards, > > Dharam > > This message is confidential and subject to terms at: http:// > www.jpmorgan.com/emaildisclaimer including on confidentiality, legal > privilege, viruses and monitoring of electronic messages. If you are not > the intended recipient, please delete this message and notify the sender > immediately. Any unauthorized use is strictly prohibited. > > > > This message is confidential and subject to terms at: http:// > www.jpmorgan.com/emaildisclaimer including on confidentiality, legal > privilege, viruses and monitoring of electronic messages. If you are not > the intended recipient, please delete this message and notify the sender > immediately. Any unauthorized use is strictly prohibited. > -- null
RE: How to handle string as java date type
Ok even if I convert it long format, how I can use that in compare expression Assuming data as below, {"id":"5","eventId":"Event4","intField":400,"currentDate": 1471254472000,"legalDate": 1471254472000} select e from /Event e where to_date(e.currentDate,'/MM/dd') > to_date(‘2018/02/20’,’/MM/dd’) from /Event e Query is invalid due to error - Syntax error in query- expecting StringLiteral, found 'e' Regards, Dharam From: Gang Yan [mailto:g...@pivotal.io] Sent: Thursday, May 11, 2017 8:11 PM To: user@geode.apache.org Subject: Re: How to handle string as java date type hi Dharam maybe you can try to_date. but for reason of performance, I think that you can choose a long to represent a date value instead of a string. Thanks and regards Gang Yan(闫钢) Sr. Solution Architect Customer Success, Pivotal Great China Mobile:+86 13636347460 g...@pivotal.io<mailto:g...@pivotal.io> 2017-05-11 21:43 GMT+08:00 Thacker, Dharam <dharam.thac...@jpmorgan.com<mailto:dharam.thac...@jpmorgan.com>>: Hi Team, Is there any good way to play with DateType if I have PdxInstance data having date string with type [java.lang.String]? Example: "duedates": { "legalDate": "2022-04-19", "currentDate": "2022-04-19", } My goal is to get results based on date comparison, select i from /Event i where i.duedates.legalDate > ‘2022-04-15’ Thanks & Regards, Dharam This message is confidential and subject to terms at: http://www.jpmorgan.com/emaildisclaimer<http://www.jpmorgan.com/emaildisclaimer> including on confidentiality, legal privilege, viruses and monitoring of electronic messages. If you are not the intended recipient, please delete this message and notify the sender immediately. Any unauthorized use is strictly prohibited. This message is confidential and subject to terms at: http://www.jpmorgan.com/emaildisclaimer including on confidentiality, legal privilege, viruses and monitoring of electronic messages. If you are not the intended recipient, please delete this message and notify the sender immediately. Any unauthorized use is strictly prohibited.
How to handle string as java date type
Hi Team, Is there any good way to play with DateType if I have PdxInstance data having date string with type [java.lang.String]? Example: "duedates": { "legalDate": "2022-04-19", "currentDate": "2022-04-19", } My goal is to get results based on date comparison, select i from /Event i where i.duedates.legalDate > '2022-04-15' Thanks & Regards, Dharam This message is confidential and subject to terms at: http://www.jpmorgan.com/emaildisclaimer including on confidentiality, legal privilege, viruses and monitoring of electronic messages. If you are not the intended recipient, please delete this message and notify the sender immediately. Any unauthorized use is strictly prohibited.