I know I can send GET requests to the YouTube API specifying startDates and endDates using a format YYYY-MM-DD, but I'm hoping there is a certain format you could specify to tell the start date to be equal to the published date or upload date?
My simple query is as follows:
startDate <- "2020-01-01" # THIS IS WHAT I'D LIKE TO CHANGE TO BE THE PUBISHING OR UPLOAD DATE
endDate <- Sys.Date()
token <- MY_TOKEN
url <- paste0("https://youtubeanalytics.googleapis.com/v2/reports?",
"&ids=channel%3D%3DMINE",
"&startDate=", startDate,
"&endDate=", endDate,
"&metrics=views,estimatedMinutesWatched,averageViewDuration",
"&filter=video==", MY_VIDEO_ID)
myRequest <- GET(url, token)
I know that you can query from the Data API first, get the published date, and then use that to feed into your query, but I'm hoping to save on API credits because I need to analyze lots of videos.
I found the easiest thing to do is just specify Jan 1, 2000 as the start date, and that seems to work.
Related
I work with gmailR and powerBi and I observe that my email data have different message "time" in Rstudio (correct time UTC+1, same that in gmail account) and PowerBi (wrong time, UTC+0) when I using same query code in both tools.
Screen:
[sorry I don't know how to insert image properly ]
link:
https://ibb.co/TM12Bk1
My query code is based on gmailR, i get specific data in list's from gmail and transform to table (tibble object in R). Then I run code in PowerBi as data source.
I get time from message list, not fuction gm_data (because of cases when this function get null values). Below sample code:
gmail_DK<- msgs_meta_DK %>% {
tibble(
date = map_chr(., "internalDate")
)
and then I change timestamp to normal data time. Sample code:
mutate(date = as.POSIXct(as.numeric(date) /1000, origin="1970-01-01"))
I checked regional settings in PowerBi Deskop and it is correct - UTC+1.
I'm in UTC+1 time zone, gmail account is for UTC+1 (this is customer service email, but as I know all customer agent's are too in UTC+1 time zone) and most of message are from and to UTC+1 users.
I can change this difference using PowerQuery or just add hour in my query code in R, but I'm curious why is this difference happen?
How Google Sheet looks
How Firebase Database looks
So the date keeps saving as the day before date;
At Google script appsscript.json is set my real timezone:
"timeZone": "Europe/Kiev"
Any suggestions?
It sounds like the two timestamp values actually refer to the same moment in time. Firebase timestamps are always in UTC.
2021-05-16 00:00 GMT+3 refers to the same point in time as 2021-05-15 21:00 GMT+0. The timezone difference between Kiev and GMT is two hours + one hour because of daylight saving time, so during EEST the two serialized values will look like they are three hours apart.
You can deal with the timezone difference in the client, displaying the timestamp value you retrieve from Firebase in the local time of the client. If the client is in the Kiev timezone, the value will then look the same as it was in the Google Sheet originally.
If you want to save the date as a static text string instead of as a Date object, you may want to convert it in Apps Script with const timezone = SpreadsheetApp.getActive().getSpreadsheetTimeZone() and const dateString = Utilities.formatDate(myDate, timezone, "yyyy-MM-dd"), or in JavaScript with the Intl object or a library like moment.js.
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'
I am new to this forum so I hope I asking my question in the right place.
I have a problem inserting a datetime into a Google Spreadsheet from a form created in Appinventor2;
In app inventor2 I created a form that fills in a google spreadsheet. Basically I merged the Pizza Party example (http://appinventor.mit.edu/explore/ai2/pizzaparty.html) with this example http://puravidaapps.com/spreadsheet.php to use google spreadsheet instead of fusion table.
the user selects in how many minutes he wants his order and then sees all the orders in a table sorted by delivery time.
Problem A)
Firstly, i want to save the current datetime + the desired delay into the google spreadsheet and sort the table by this new datetime.
1) when i use the block "call clock format time" + "call clock addminutes" the spreadsheet is populated with a text, but then i can't sort the table by delivery datetime. in fact i believe the sorting is done on the number regardless of the am/pm or day of the month. so for example instead of having 4am, 6am, 2pm, 3pm i get : 2pm, 3pm, 4am, 6am.
2) I then tried to remove the block "call clock format time" and in the google form i kept the field format = text
but the google spreadsheet is populated with the following:
java.util.GregorianCalendar[time=1395531335908,areFieldsSet=true,lenient=true,zone=Europe/Dublin,firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2014,MONTH=2,WEEK_OF_YEAR=12,WEEK_OF_MONTH=4,DAY_OF_MONTH=22,DAY_OF_YEAR=81,DAY_OF_WEEK=7,DAY_OF_WEEK_IN_MONTH=4,AM_PM=1,HOUR=11,HOUR_OF_DAY=23,MINUTE=35,SECOND=35,MILLISECOND=908,ZONE_OFFSET=0,DST_OFFSET=0]
3) I then tried to remove the block "call clock format time" and in the google form I changed the field format = time
but then the google spreadsheet isn't populated with anything.
4)I tried using the segment block, but after a while I realised the block "format time" actually returns this format: "hh:mm:ss AM/PM"
so selecting the 5 characters is not good enough because it does not take into account of the am/pm element as well as the day of the month.
5) I found a temp solution by defining the desired delivery time as a new global variable, and extracting a string in the format hh:mm by joining the blocks ".hour instant" and ".minute instant".
However this is not a final solution because what i extracted is of course a string of text and when sorting, 01:10 will be always considered smaller than 23:50 for example, regardless of the date.
So is there a way of actually saving in the google spreadsheet not a string of text, but actually the date and time?
Problem B)
Secondly, I would like to filter/show only the rows of the google spreadsheet have a delivery time expired by no more than 1 hour (as well as orders with delivery time in the future e.g. in 2 hours from now()).
I tried using some Google Visualization API Query Language commands, altering the url of the google spreadsheet (like WHERE "now() - Delivery Time < 60 mins)" (cannot remember the exact code I wrote) but unsucessfully.
Would anyone know how to filter my results?
thanks in advance
alterettore
So there's a few things to note.
If you're using Taifun's example as you mention, you'll notice that when you submit data to Google Spreadsheets using a form, the first column is always a timestamp, even if you're not submitting a date or time. Trying to send the current date/time is redundant - go ahead and make use of what Google provided.
Google Spreadsheets (and Excel) store Date/Time as a number. If you want to store a date in GS, the best way to do so is not formatted text, but by sending a number. Use AppInventor to calculate the number you need. For example, today (April 27) in GS is 41756. Noon today would be 41756.5
To generate this number, start with AI's Millisecond function. NOTE: Both GS and AI use milliseconds, but they have different 0 points, so you have to manipulate the result a bit. The formula I've used in AI in the past is this:
GS Date/Time = (Clock1.GetMillis(Clock1.Now) / 86400000) + 25569
Hope this helps!
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)