I have a YQL query where I am accessing data from an RSS feed. I want to get the pubDate for the articles in the feed, but I don't want it to be in (for example) this format:
Fri, 30 Nov 2012 14:19:55 +0000
I would prefer it to be in this format:
11/30/2012
Is there a simple function within YQL itself that would let me do this? Just to be clear, I would prefer to have a YQL-only solution, without having to use PHP or javascript or anything.
Check this link. In particular look at y.date.getOffsetFromEpochInMillis(time_format) function. This gives you the epoch in milliseconds.
After you get that, inside your YQL open data table definition, massage this timestamp to mm/dd/yyyy format as listed in the question Convert a Unix timestamp to time in JavaScript
Related
I am having trouble formatting a date in Gatsby. I have sourced some data from firestore. One of the fields that I have sourced is called datePublished and it contains a number in the form of a timestamp (e.g., 1576945502000). Indeed, it really is a timestamp, but it got saved to firestore in the number format type.
Now, I would like to format the datePublished field using the formatString function in graphql -- as noted here: https://www.gatsbyjs.org/docs/graphql-reference/#dates
But I can't get the formatting to work. Whether I try to format the string in graphiql or on my site, it does not work. Here is the code that I tried:
query MyQuery {
allNewsFeed {
edges {
node {
published(formatString:"dddd Mo, YYYY")
}
}
}
}
And this is the error message that I get in graphiql:
Unknown argument "formatString on field 'datePublished' of type 'NewsFeed'.
If I dig a little deeper, I notice that the field type in firestore is listed as number and in the graphiql document explorer it is listed as a FloatQueryOperatorInput.
What's more, I did a little experiment where I tried to save the same number as a string, number and timestamp in firestore. Neither the string or number format worked and for whatever reason, the gatsby-firesource plugin will not pull in the field with a timestamp format.
So I am wondering, what do I have to do to get this to work in gatsby?
Any ideas?
Thanks.
I had a similar situation with Gatsby not accepting "formatString" on a date field, for me what solved the issue was to change the format of the field to YYYY-MM-DD so it went from 02 06 2017 to 2017-06-02 and gatsby got the hint that that field represents a date.
It seems gatsby "reads" the data and guesses the type and based on that we get certain functionality.
Since gatsby uses moment.js I'm guessing the YYYY-MM-DD format is picked up by it.
I'm using MDX so it was really easy for me to change the format of my date field since it's just plain text, I'm not sure you have the same luxury with firestore but I hope this at least give you some ideas to try out. Good luck!
I sent the following string to Marketo REST API to be set as the value of a datetime field:
"2010-05-07T15:41:32"
But Marketo displays it as:
May 6, 2010 8:00 PM
Is there something i'm missing?
It is always a bit tricky to deal with DateTime properly.
Most probably there are two, but related issues here:
The format of the datetime string you are using is not exactly the format that Marketo expects.
You are living in a timezone that is different to the internal timezone Marketo uses.
Luckily, you can easily overcome this issue.
The exact format for the datetime string should follow the ISO 8601 standard, as it is described in the Field Types section of the documentation. An important part of that specification is the timezone offset, which follows the “normal” datetime part as the difference to Greenwich time in the form of ±hh:mm. So, depending on your timezone, your date string should look like somthing like this: 2017-05-08T08:08:08+02:00. (Where +02:00 is for Central Europe.)
In case you are using PHP, the easiest way to have this format is by using the c full Date/Time format, like so:
$date = new DateTime('2010-05-07 15:41:32', new DateTimeZone('Europe/Budapest'));
$dateString = $date->format('c');
var_dump($dateString);
// outputs: '2017-05-08T08:08:08+02:00'
The Google Search Appliance goes through and finds out the date of each article when it crawls (last modified date is the default).
However, it doesn't turn up articles when you query by date code.
Is there any way to get the GSA to do this?
(We have a daily broadcast which people often search for by date code. Right now we have to manually put in the 4 most common date codes into the meta-keywords in order for them to be pulled up through a query)
Have you tried using inmeta:date as described in the Search Protocol Reference documentation?
Alternatively, if the date code is in the document content or the URL you could use entity recognition to extract it.
One way to make sure GSA is collecting the document date is to check the search results in XML format and see if tag has the date value. You can see the results in XML format by removing any proxystylesheet parameter in the URL.
If the value of tag is empty then GSA is not getting the document dates.
You can configure the document dates under Crawl and Index > Document Dates (at least at GSA version 7). We are using a meta tag approach. We put a date meta tag to each document/page and tell GSA to use this meta tag to sort the documents. The full list of options are:
URL
Meta Tag
Title
Body
Last Modified
Here are some links that helped me to find answers when dealing with a similar problem:
https://support.google.com/gsa/answer/2675414?hl=en
https://developers.google.com/search-appliance/documentation/64/xml_reference#request_sort_by_date
https://groups.google.com/forum/#!searchin/google-search-appliance-help/sort$20by$20date$20not$20working
I have to make an ezfind search page with date functions. For the SOLR filter I tried to use something like this: attr_publish_date_dt:[NOW-6MONTH TO NOW] but I don't get any result.
If I use it this way attr_publish_date_dt:[* TO NOW], it works. But all queries without an asterisk on the left hand don't work.
attr_publish_date_dt contains a unix timestamp so I also tried to use 2 timestamps from the attr_publish_date_dt:[* TO NOW] result, instead of [NOW-6MONTH TO NOW], but then I get also no results.
Can anyone help me please? Thanks in advance
Frank
Date searches are supported on a date field. You will need to define a field of that type, and submit dates in ISO-8601 format.
http://lucene.apache.org/solr/4_4_0/solr-core/org/apache/solr/schema/DateField.html
If you cannot properly format the timestamp before sending it to Solr, you may be able to use a DateFormatTransformer or a ScriptTransformer to do the job.
http://wiki.apache.org/solr/DataImportHandler#DateFormatTransformer
http://wiki.apache.org/solr/DataImportHandler#ScriptTransformer
Are there any simple HTTP APIs out there which will let me get the stock price for a symbol (such as GOOG) at a specific date and time?
Something like...
http://somewebsite.com/?
symbol=GOOG&
year=2010&
month=7&
day=30&
hour=4&
minute=00
Giving a response of $484.85
I'm hoping to have an end result of a haskell function whose type signature looks something like...
getQuote :: Symbol -> Date -> Time -> Price
I believe YQL with Yahoo finance can complete this task, they have data going back to 1996 looking on some stocks.
http://www.yqlblog.net/blog/2009/06/02/getting-stock-information-with-yql-and-open-data-tables/
http://www.gummy-stuff.org/Yahoo-data.htm
Here is an example on how to get the data in JSON-format from 2014-01-01 to 2015-01-01 for Apple stock (AAPL) via Yahoo Finance API using YQL.
The YQL query is URL-encoded:
select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%3D%22AAPL%22%20and%20startDate%3D%222014-01-01%22%20and%20endDate%3D%222015-01-01%22
So, if you decode it, you'll get:
select * from yahoo.finance.historicaldata where symbol="AAPL" and startDate="2014-01-01" and endDate="2015-01-01"
Just change the date values to ones you want and decode the whole thing back, for example using this URL-encoder: http://meyerweb.com/eric/tools/dencoder/
Then, put the whole thing together by adding the encoded query into the request URL:
http://query.yahooapis.com/v1/public/yql?q={ENTER_QUERY_HERE}&env=http://datatables.org/alltables.env&format=json
So, you end up with something like this:
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%3D%22AAPL%22%20and%20startDate%3D%222014-01-01%22%20and%20endDate%3D%222015-01-01%22&env=http://datatables.org/alltables.env&format=json
Which will return you some fine JSON-formated data for the time period you've set.
Take a look at the Historical Securities Data API at http://www.mergent.com/servius - I don't think they'll have intraday data though...
You can find historic intraday data at http://www.myinvestorshub.com/historic_intraday_data.php ( for all countries)