Question: I've been trying to use a Single JavaScript object in multiple files. For that I chose singleton design pattern in JavaScript.

**mySingleton.js**

```
var mySingleton = (function () {
var instance;
function init() {
function privateMethod(){
    console.log( "I am private" );
}
var privateVariable = "Im also private";
var privateRandomNumber = Math.random();

return {

  publicProperty: "I am also public",
  publicMethod: function () {
    console.log( "The public can see me!" );
  },

  getRandomNumber: function() {
    return privateRandomNumber;
  }

  };

};

return { 

getInstance: function () {
  if ( !instance ) {
    instance = init();
    console.log("Newly creating an object");
  } 
  return instance;
} 
};
})();
module.exports = mySingleton;

```

And i'm Accessing the The above object in a separate node js file. As showed in following code

**test.js**

```
var singleton = require('./mySingleton');
var obj = singleton.getInstance();
console.log(obj.publicProperty);
console.log('random number value:'+obj.getRandomNumber());

```

**test2.js**

```
var singleton = require('./mySingleton');
var obj = singleton.getInstance();
console.log(obj.publicProperty);
console.log('random number value:'+obj.getRandomNumber());

```

When i execute the above two files each time a new javascript object is creating. But I want to use the same JavaScript object in multiple files.

Thanks in advance....

So Can anyone please give any suggestion to achieve the above functionality.

Answer: 
Looking at the issue Dateofbirth is probably a datetime column.

A datetime column has both a date part and time part.So, your query with date alone will translate as 

```
SELECT * FROM student
WHERE Dateofbirth >= '2014-10-03 00:00:00.000'
AND Dateofbirth <= '2014-10-03 00:00:00.000'

```

So, to get the entire day the query should be like 

```
SELECT * FROM student
WHERE Dateofbirth >= '2014-10-03 00:00:00.000'
AND Dateofbirth <= '2014-10-03 23:59:59.997

```
```
SELECT * FROM student
WHERE Dateofbirth >= '2014-10-03'
AND Dateofbirth <= '2014-10-03'

```

This means show only data which have only `2014-10-03` value. There is hour is also in your date, and your date string is without hour,minute, second. So in compare it will not get. 

The problem will solved by type casting or proper format need when you working with date compare.

```
SELECT * FROM student
WHERE cast ( Dateofbirth as date) >= cast ( '2014-10-03' as date)
AND cast( Dateofbirth as date) <= cast( '2014-10-03' as date)

```

This will set both value in date portion not time.

When you use `2014-10-04` mean all hours including and get the result.

OR 

you can user between operator also, which include the starting date and ending date.

```
SELECT * FROM student
WHERE cast ( Dateofbirth as date) between cast ( '2014-10-03' as date) and cast ( '2014-10-04' as date)

or 
SELECT * FROM student
WHERE Dateofbirth  between '2014-10-03' and '2014-10-04' 

```