what is query to change the data type of Date from string date time format in elastic search? - string

I am working on an elastic search. I need to change the data type from string to date format.
The field name and its value is the date and 2020-02-01 08:17:22.438000. Now it is I string data type. I need to change into the date-time format in the elastic search itself.

Related

HANA SQL:Import Excel Field formatted as date into Dataset or convert excel date values (eg. 43830 for 31.12.2019) to Date

I'd like to upload from an Excel file with a column formatted as date in excel to a dataset in the Analytical workspace of Tagetik on HANA database.
As excel stores date values as numbers (eg43830 foe 31.12.2019) I get an orror uploading in a dataset field with type date as 43830 is not a valid date format.
Uploading the excel field in a Dataset field with type text or number works, but then I have the numeric representation there.
So I'd like to convert this number (43830) to a valid date (31.12.2019) - I did not find an appropirate function in HANA SQL.
Thanks for some ideas.
best
Sabom
Why do you dont convert the number to a date as string in excel before upload and just use that date? Sounds like the easiest. Nontheless, you could use ADD_DAYS in HANA. The number you are seeing are days since January, 1st 1900. So ADD_DAYS with a base of 1900-01-01 should work.

Specifying timestamp or date format in Athen Table

I have a timestamp in ISO-8601 format and want to specify it either as a timestamp or datetime format when creating a table in Athena. Any clues on how to do this ?
Thanks!
When you create table in Athena you can set a column as date or timestamp only in the Unix format as follows:
DATE, in the UNIX format, such as YYYY-MM-DD.
TIMESTAMP. Instant in time and date in the UNiX format, such as
yyyy-mm-dd hh:mm:ss[.f...]. For example, TIMESTAMP '2008-09-15
03:04:05.324'. This format uses the session time zone.
If the format is different, define it as a String and when you query the data use the date function:
from_iso8601_date(string) → date
You can convert the data to make it easier and cheaper for specific use cases by using CTAS (create table as select) query that will generate a new copy of the data in a simpler and more efficient (compressed and columnar) parquet format.

Handling SQL date as string with node-mssql

I'm using node-mssql to get rows from a table that includes a date column (YYYY-MM-DD). I want to pass the date to a client application as a string in that same format. node-mssql is creating date objects, which I'm having to convert and slice at significant cost to get the format that I started with. sql.map.register(String, sql.Date) doesn't seem to work here (or I'm using it wrong). Is there a way to change how node-mssql handles the SQL date data type?
I'm having the same problem. sql.map.register is only for converting JS types to SQL types and I don't think there is any way to avoid SQL Date fields being converted into JS Date objects with node-mssql alone. I just changed my SQL query to convert to a formatted varchar instead of a Date type, e.g.: convert(varchar, birthday, 105) as dob.

Logstash convert the "yyyy-MM-dd" to "yyyy-MM-dd'T'HH:mm:ss.SSSZ"

I use the logstash-input-jdbc plugin to sync my data from mysql to elasiticsearch. However, when I looked at the data in elasticsearch, I found that the format of the fields of all date types changed from "yyyy-MM-dd" to "yyyy-MM-dd'T'HH:mm:ss.SSSZ".I have nearly 200 fields whose type is date, so I want to know how to configure logstash so that it can output the format "yyyy-MM-dd" instead of "yyyy-MM-dd'T'HH:mm:ss.SSSZ".
Elasticsearch stores dates as UTC timestamps:
Internally, dates are converted to UTC (if the time-zone is specified) and stored as a long number representing milliseconds-since-the-epoch.
Queries on dates are internally converted to range queries on this long representation, and the result of aggregations and stored fields is converted back to a string depending on the date format that is associated with the field.
So if you want to retain the yyyy-MM-dd format, you'll have to store it as a keyword (which you then won't be able to do range queries on).
You can change Kibana's display to only show the yyyy-MM-dd format, but note that it will convert the date to the timezone of the viewer which may result in a different day than you entered in the input field.
If you want to ingest the date as a string, you'll need to create a mapping for the index in question to prevent default date processing.

DSE Solr date range query for String date 'yyyymmdd' & integer hour

I'm using Datastax Solr version 4.8. I've column with string values of date in 'yyyymmdd' format and another column with int values of hour. Now the requirement is to fetch all the records say from yyyymmdd - '20161110' to '20161130' and from hour 21 to 15.
Is there any way to get this search using DSE Solr?
I would suggest you to use a copy copy field with that string date as the source and a date field as the destination. Once your string date has been converted into an actual proper date you can query it like a normal date 'AND' the hour into the query. Hope it helps.
Finally I ended up adding timestamp column to get the date range query result.

Resources