SOLR convert string to date - solr

I have a dynamic field in SOLR that its value is stores as string
The value in it is a date string like:
"md_LocalStartTime": "2013-01-31T22:12:54.8000000+0000",
I want to get the max value for this
What wuery should I use to convert this to date and get the maximum?
Thanks

As a matter of fact, with this kind of date string representation lexical order is also date order, so ...sort=md_localStartTime%20DESC&rows=1&start=0

Related

Input string was not in a correct format using decimal data type

when I fill up the form and filled the contact no field then getting an error:
form contactno field:
contactno : 0101001010
Input string was not in a correct format
Database Editor:sql server management studio
table field : contactno(decimal(18, 0))
how to solve this issue?
As a general rule: can you do calculations wth a field? No? Then it's not a number; store it as NVarchar/string. Prices, amounts, VAT and discounts, all valid numbers. ID's, zipcodes, phone numbers not so much. What is an ID code + 1000?
In your case, the contactno seems to be an ID, not an arithmetic number. You're trying to store the value 0101001010 as a number, but numbers can't have prepended zeroes. This is what generates the string in invalid input format error.
The best fix would really be to make this field in the database a text-based column and treat the contact number as text throughout your code.

conversion failed when converting date from character message

I receive a file monthly that for some reason has service_date as a char(8) data type. The image shows some of the things that are entered and the second column is the length of the service date field. Is there a way for me to clean up the bad dates? I was hoping if the length was shorter or longer I could eliminate them but it doesn't seem like it will work. Any ideas on what the best way to fix this field would be. Thanks.
You can use the try_convert function to attempt to convert your Service_Date values into a date and excluding any where a null is returned.

Material-table CustomSort doesn't work with Dates

I receive a column from api that contains Dates + _number (example: "20/12/2019_1" as a string). The sort function will group counting data as a string and not as a Date column. Which means i need to do a customSort.
So i created a function to transform that string into a Date object, but when i return the value nothing happens...
Columns:
utils.js:
The formatLot function is working as expected since i wanna Sort value as type Date.
Result from formatLot function:
You are using the custom sort incorrectly.
As seen in the docs, you have to return the comparison of two dates as a number, but you are only returning the date object.
Change it to and it will work:
customSort: (a,b) => formatLot(a.test).getTime() - formatLot(b.test).getTime()

Snowflake variable data types

I am trying to declare a session variable to a date value but the variable keeps reading in as string or numeric.
I've tried setting the date with varying formats, with and without time, in utc format, etc but nothing has worked. All are seen as text unless i don't use quotes or apostrophe's, in which case 2019-09-01 results in 2009 number type.
set(myDate)='2019-09-01'
set(myDate)="2019-09-01"
set(myDate as date)='2019-09-01'
set(myDate)='2019-09-01 18:25:53.820000000Z'
no matter what i try when i run show variables it doesn't show as date or timestamp data type. if i run set(myDate)=current_timestamp() that works fine but I do not want the current date.
Finally figured it out so maybe this will help someone else. When setting the variable, use to_date to cast the value at the same time. e.g:
set(myDate)=to_date('2019-09-01');

How to convert long value to date using adf el expression?

I am using an ADF application. I have stored the date value in long format in my database.
I am using the input date format.
my coding is given bellow
<af:inputDate label="Label 1" id="id1" value="#{pageFlowScope.TestBean.date}"/>
I want to convert the long value to date format using El expression if it's possible to convert long to date using all expression?
Thanks in advance
You are probably looking for the af:convertDateTime component.
Or you could set the date format directly in your VO (if your attribute is mapped to Timestamp).
In the back bean, you should have a Date variable ready already, you could use new Date(your_long_value_variable) to create a Date object. Then bind the date object with the value of your inputText/outputText, then use the af:convertDateTime to convert the format. For example:
<af:outputText value="#{your_date_variable}"
id="example1">
<af:convertDateTime type="both"
timeZone="GMT"/>
</af:outputText>
The type attribute specifies what contents the string value will be formatted to include, or parsed. Valid values are "date", "time", and "both". Default value is "date".
And timezone attribute is in which timezone to interpret any time information in the date string. And you can also edit the pattern attribute to decide the date format.
You could also modify the "pattern" attribute to change the format.
Plus, http://docs.oracle.com/cd/E15051_01/apirefs.1111/e12419/tagdoc/af_convertDateTime.html is the link for the af:convertDateTime.

Resources