I made a script in local development machine mongoDb 4.0 its working flawless but for client server MongoDb is 2.6 so $dateToString is not supported. is there any substitute using $dateToString into mongoDb 2.6. Using MongoDb 4.0 : Output : But in MongoDb 2.6 Iam getting Error : Database design : Answer In MongoDB 2.6 you would need to use