sphinx search with date - sphinx

I am creating index on sphinx compatible xml data.
In my file i have tag of date for which i define type as timestamp.
Data for that tag is like below
"Thu, 7 Jun 2012 00:00:00 PDT".
I have define tag as
<sphinx:attr type="timestamp" name="rss.channel.item.pubDate"/>
in my Sphinx compatible xml document.
Problem is,when i try to search using this data it does not give me any index related to it.
So how can i index and search for date in sphinx?

Its expected to be a numeric timestamp, rather than a string
http://sphinxsearch.com/docs/current.html#conf-xmlpipe-attr-timestamp
you will have to convert it first.

Related

Date Time and Conversion Functions not available in MS Access 365 at Table Design Time

I'm trying to simply convert a text field into a datetime value in MS Access 365. This should be simple. However I don't seem to have access to functions like Date(), DateValue().
I want something where I can just pass some text in and it converts to a datetime type. My data looks like this:
I used the formula: I used this formula to get this: Left$([DateText],InStr(1,[DateText]," - "))
to remove the time from the DateText field.
Now I want to add a new field which is a date/time type using the data in the DateTextWithTimeRemoved field.
The table design view (also showing the conversion functions available) is like this:
And the date functions are these:
And so, from years ago I remember using functions like CDate() or Date() or DateValue() or what have you, but they're just not there. Do I have to install something to get these functions?
Assuming you want to keep the same Table fields shown in your question:
Make a backup of your current table.
Change the Data Type of the DateThatIsAnActualDate field to Date/Time and DateTextWithTimeRemoved to Short Text.
Create an an Update Query. (Create -> Query Design -> select Update under Query Type.)
Add your Table (members)
Field: DateTextWithTimeRemoved
Table: members
Update To:
Left([DateText],InStr(1,[DateText]," -"))
next column
Field: DateThatIsAnActualDate
Table: members
Update To:
Format(DateValue(Left([DateText],(InStr(1,[DateText]," -")))),"dd/mm/yyyy")
Click Run !
Click Yes to confirm.
All done. Check the records in the members table.
First, forget about the calculated fields. Use queries, that's what they are for. Tables are for data.
Second, the Expression Builder is hopeless. I have never found it useful.
Next, all you need for an easy conversion to true date values, is to remove the dash.
TextDate = "10 Dec 2020 - 16:52"
? Replace(TextDate, "-", "")
10 Dec 2020 16:52
This can be converted like this:
' Date only:
? DateValue(Replace(TextDate, "-", ""))
2020-12-10
' Date and time:
? CDate(Replace(TextDate, "-", ""))
2020-12-10 16:52
Now, your query could look this this:
Select
ID,
Username,
DateValue(Replace(TextDate, "-", "")) As TrueDate,
CDate(Replace(TextDate, "-", "")) As TrueDateTime
From
Members
Note, that date/time values carry no format. Apply this for display only, so adjust the Format property where needed (the forms/reports where you view the data), if the default format (that of your Windows settings) doesn't fit.
Format: dd/mm/yyyy
The default is:
Format: Short Date

I am using OpenXML in C# for creating xlsx file but date comes as Jan 1900

In C# I am using OpenXML document format spreadsheet to create xlsx file. but excel gets created with date 'Jan 1900'. I am applying stylesheet document to spreadsheet document. Please help to get exact date.
I expects date should be 01/01/2019 which comes from datatable but actual output is Jan 1900
I think one of the solutions is to use the TEXT function.
Let's say you have a variable contains the date named dDate.
Then, put this in the cell where you want the value to be displayed:
=text(dDate,"mm/dd/yyyy")
Maybe you need to use C# grammar to do the concatenation of the string and the variable.

Hive datatype confusion

I have a large data and in that one field be like Wed Sep 15 19:17:44 +0100 2010 and I need to insert that field in Hive.
I am getting troubled for choosing data type. I tried both timestamp and date but getting null values when loading from CSV file.
The data type is a String as it is text. If you want to convert it, I would suggest a TIMESTAMP. However you will need to do this conversion yourself while loading the data or (even better) afterwards.
To convert to a timestamp, you can use the following syntax:
CAST(FROM_UNIXTIME(UNIX_TIMESTAMP(<date_column>,'FORMAT')) as TIMESTAMP)
Your format seems complex though. My suggestion is to load it as a string and then just do a simple query on the first record until you get it working.
SELECT your_column as string_representation,
CAST(FROM_UNIXTIME(UNIX_TIMESTAMP(<date_column>,'FORMAT')) as TIMESTAMP) as timestamp_representation
FROM your_table
LIMIT 1
You can find more information on the format here: http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
My advice would be to concat some substrings first and try to convert only the day, month, year part before you look at time and timezone et cetera.

Xpath current date

I have a webpage where a row displays name, relation and date. I want to search for the matching row as per my values. Using Xpath, I have built the below mentioned code. The only problem is the last part (the date). I want to pick up the current date and fit it into the search query..i.e. instead of 30 Sep 2013, I want it to search for 01 Oct 2013 (assuming today is this date).
Any clue how can i do that??
$x('//tr[descendant::b[text()="text1"] and descendant::a[#class="bill" and text()="for Automation"] and descendant::td[text()="30 Sep 2013"]]')
You have to build the expression dynamically and append the date string at the end based on some date object. The specific implementation depends on which programming language you're using

How to convert from string to date data type?

I am uploading data from a csv file to MongoDB. It is taking OrderDate as string data type due to which facing problems while creating reports using a BI tool.
I have about 10000 records in my collection.
Could anyone help me how can I change the data Type of OrderDate to Date with a single query?
I don't think that you can change field's type with single query. The easiest way is to convert data strings into Date format using ISODate function during the insertion. But, if you want to process the data you already inserted, you can do it with the following code using mongodb console:
db.collection.find().forEach(function(element){
element.OrderDate = ISODate(element.OrderDate);
db.collection.save(element);
})
This code will process each element in your collection collection and change the type of Orderdate field from String to Date.
db.messages.find().forEach(function(doc) {
doc.headers.datestamp = new Date(Date.parse(doc.headers.Date.toString()));
db.messages.save(doc);
})
This worked well to convert this sort of text:
Tue, 14 Nov 2007 03:22:00 -0800 (PST)
The text is from an email archive known as the Enron Corpus.