MongoDb cube: display unix timestamp as a date

4 views
Skip to first unread message

Q&A Bot

unread,
Mar 21, 2021, 6:36:44 AMMar 21
to seektab...@googlegroups.com

Q:
We have a field in our MongoDb that stores data as a milliseconds (unix timestamp). Is there a way to display it as a date in SeekTable reports?

To do that it is enough to add the following projection for the dimension that corresponds to the unix timestamp field:
  • dimension type should remain Type=Field
  • add to "Parameters" one entry:
    {"$toDate":"$unix_timestamp_field"}    
In a similar way you can add dimensions for the date-parts of this date like year/month/day, for example:
  • Type=Field
  • Name=unix_timestamp_field_year
  • "Parameters" entry:
    {$cond: [{ $ifNull: ["$unix_timestamp_field", 0] }, {"$year":{"$toDate":"$unix_timestamp_field"}}, -1]}
Reply all
Reply to author
Forward
0 new messages