Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. split time then group by 15 min mongodb

split time then group by 15 min mongodb

Scheduled Pinned Locked Moved Database
databasemongodbxml
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 12973039
    wrote on last edited by
    #1

    I have a Schema in mongodb like:-

    {
    _id: ObjectId("5e05c1089b3e4e333cee8c39"),
    name:"Alex",
    activity:[{
    {
    _id: ObjectId("5e05c1089b3e4e333cee8c39"),
    type: 'run',
    start_timestamp: ISODate("2020-01-11T11:34:59.804Z"),
    end_timestamp: ISODate("2020-01-11T11:40:00.804Z")
    },
    {
    _id: ObjectId("5e05c1089b3e4e333cee8c40"),
    type: 'stop',
    start_timestamp: ISODate("2020-01-11T11:40:00.804Z"),
    end_timestamp: ISODate("2020-01-11T11:42:00.804Z")
    },
    {
    _id: ObjectId("5e05c1089b3e4e333cee8c41"),
    type: 'wait',
    start_timestamp: ISODate("2020-01-11T11:42:00.804Z"),
    end_timestamp: ISODate("2020-01-11T11:52:00.804Z")
    },
    }]
    }

    This is a schema for a man activity, i need to find brake-up of every 15 minute (brake-up duration in minute) like

    {
    _id: "2020-01-11T11:34 to 2020-01-11T11:49" ,
    duration: 15,
    brake-up:{
    run:6,
    stop:2,
    wait:7
    }
    }

    here type: wait should be split into 2 duration "2020-01-11T11:34 to 2020-01-11T11:49" 7 min and "2020-01-11T11:49 to 2020-01-11T12:04" 3 min .

    {
    _id: "2020-01-11T11:34 to 2020-01-11T12:04" ,
    duration: 15,
    brake-up:{
    wait:3
    }
    },

    Thanks

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups