Kibana Field Conversion - Transforming Unix Time into Date - kibana

I was wondering if there is a way to convert a field that is being received in Unix Time (long) into a fully readable Date in the Kibana environment.
My application is sending JSON logs to Kibana. Two of the log fields are numbers representing a UnixTimeStamp. In this case, the begin and end dates of a procedure.
{
beginDate: 1669734768,
endDate: 1669734780
}
This means that when I try to access these fields in a Table Visualization, the data is represented as it shows.
Table View of the problem
Is there a way to parse this UnixTimeStamp into a more user-friendy date model so that it is easier to read in the Visualization?
Something like "May 25th 2016, 22:39:30.000" or similar.
Thank you!

Related

Is there a way to take a fixed date and change it into a date table in Lua without specifically assigning each value?

I have a date which is being fed into my script in the following format:
dateTime = "Fri Oct 18 10:08:02 UTC 2019"
Is there a way to reformat this so that I can quickly call each element as I like without explicitly splitting out using string.sub (for example)?
E.g. So that I can:
Subtract one date from another to find out age (using current time and birth/established date)
Add hours dependant on the timezone (given that I have a timezone in the format "+3")
Find if the time was between a range (e.g. the request was sent between 9am and 5pm GMT)
Lua does not have a built-in date or time type like other languages.
Lua 5.3 Reference Manual 2.1 Values and Types
There are eight basic types in Lua: nil, boolean, number, string,
function, userdata, thread, and table.
Lua 5.3 Reference Manual 6 Standard Libraries
Either implement them yourself or find existing modules that suit your needs.
A simple way would be to parse your date time string using captures
Checkout http://lua-users.org/wiki/DateAndTime for suggestions.

AppInventor: how to insert DateTime into Google Spreadsheet and show only recent DateTime

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!

Date formatting issue in Marklogic

I am using xdmp:document-filter(doc(uri)) to fetch the metadata from the documents. When I run this command on one of the documents I get the following result:-
xdmp:document-filter(doc("/Vision.doc"))//*:meta[#name eq "Creation_Date"]/#content
<?xml version="1.0" encoding="UTF-8"?>
<results warning="attribute node">
<warning warning="attributes cannot be root nodes" content="17-05-2012 00:48:00"/>
</results>
And when I run this command on another document then I get this:-
<?xml version="1.0" encoding="UTF-8"?>
<results warning="attribute node">
<warning warning="attributes cannot be root nodes" content="2012-06-03T13:45:00Z"/>
</results>
You can see that date format is different in both the outputs. There may be different date formats in documents uploaded in Marklogic Server. But I want to show the creation date of documents in some fixed format (e.g. May 16, 2012). How can I convert the different date formats to a fixed date format ? And also I want to compare these dates to the date entered by the user. The documents matching the search criteria should get returned by the search query. So I have two questions here:-
How to convert creation date of particular documents to some fixed format and to display it in the UI.
How to compare this creation date to the date entered by the user(which is in "mm/dd/yyyy" format) so that I can get the correct result.
You will have to parse the dateTime value. For example:
let $dt := "17-05-2012 00:48:00"
return
if ($dt castable as xs:dateTime)
then xs:dateTime($dt)
else xdmp:parse-dateTime("[Y01]-[M01]-[D01] [h01]:[m01]:[s01]", $dt)
This will return an xs:dateTime atomic value, which can be compared and displayed in the UI. If you want to support additional formats, you will need to create additional parse "picture" strings so they can also be converted to xs:dateTime. See the documentation on xdmp:parse-dateTime() for more information.
As a part of a larger open source project I cooked up a date parsing library that handles at least 20 different formats in 6 different languages. You can also supply your own formats if one is not already defined. It works by feeding it a date as a string in any of the defined formats and returning an xs:dateTime if it was able to successfully parse it. You can find the library here:
https://github.com/marklogic/Corona/blob/master/corona/lib/date-parser.xqy
To use it:
import module namespace dateparser="http://marklogic.com/dateparser" at "date-parser.xqy";
dateparser:parse($filteredDocument//*:meta[#name eq "Creation_Date"]/#content)
This will allow you to normalize the various date formats that binary documents can have. I will note that different binary formats (Word, PDF, JPEG, etc) will use different names for the creation date. So just looking for the "Creation_Date" metadata could leave some holes depending on what formats you're storing in MarkLogic.
Also note, that if you just want the date information without the time portion, you can cast the xs:dateTime to an xs:date. Doing so will retain the timezone information which is likely a good thing.
As for your second question…
There is a number of different ways to do this and reading some of the MarkLogic documentation is a good place to start. I'd recommend taking a look at:
http://docs.marklogic.com/guide/search-dev/rangequery
Hopefully that will shed a bit of light on what your query needs to look like. In simplest form you will probably have to first parse the date that the user provided. This can also be done with the date parsing library so users can enter tons of different date formats (eg: November 13th, 2012 or even in Spanish Noviembre 13th, 2012). Then use that parsed date to construct date range queries in MarkLogic.
If that doesn't help I'd post another question here with the specifics of where you're getting hung up.

Reporting Services: DateTime parameter not showing the time part when its midnight

I need to add a 'StartDate' parameter to a report in Reporting Services 2005, which should represent the current date, at midnight.
If I use Now() as expression, it will correctly use midnight in the calculations, but to the user, the time part will not be shown.
13/12/2011
which can be confusing because then the user doesn't really realise he or she can type in a time part.
How can I format this date to the following:
13/12/2011 00:00
while keeping the parameter as a DateTime datatype.?
Edit: I've checked the duplicate question and tried to apply it to my case, but run into the following phenomenom:
If I try:
=DateTime.Parse(Format(Now().Date().AddSeconds(1), "dd/MM/yyyy HH:mm:ss"))
Then the parameter shows "14/12/2011 00:00:01" which is confusing for the users, so I then tried the following:
=DateTime.Parse(Format(Now().Date().AddSeconds(1), "d/M/yyyy HH:mm"))
But then the parameter shows "14/12/2011" again! In other words, the time part is gone again!
Who invented this stuff? :P
Your formula with .Parse(Format(... causes redundant work that is messing things up. Try this:
=Now().Date().AddSeconds(.001)
Use Format. For example: Format(Parameters!SelectedDate.Value, "d/M/yyyy HH:mm")
Here is a list of DateTime identifiers for use with Format.
Edit:
I get it now, you want 00:00 to show up in the parameter input calendar in the report viewer. The time part won't show up when it's set to midnight. This is by design. If you're using 2005 or earlier, Jamie's solution won't work and you're stuck.

asp.net now() function with different time zones

I will be entering some values into a database based on input from users. One value will be the date and time of the input.
I'm not sure how this works at all, but a user from e.g. New York enters some data and the website is hosted in the UK...what time will be stored?
Up until now I had been using the "now()" function to record the date and time, but just occured to me that this could happen! What else should I use?
Thanks,
UTC, works in any time zone, you can either save all dates in your storage as UTC or use proper type that includes time zone data, for example in SQL 2008 you can use datetimeoffset

Resources