Skip to content

DateTime precision error. #755

Closed

Description

@heroboy

code:

var d1 = new Date(2018, 6 - 1, 11);
var d2 = new Date(d1.getTime() + 24 * 3600 * 1000 - 1); //change to -2 ,no error.
TestDate();
function TestDate()
{
	db.acquire((err, conn) =>
	{
		if (err) return;

		var request = new tedious.Request("select @v1;", function (err)
		{
			if (err)
			{
				console.log(err);
				return;
			}
			conn.release();
		});
		request.on('row', cols =>
			console.log(cols.map(x => x.value))
		);
		request.on('returnValue', (name, value) =>
		{
			console.log(name, value);
		})

		request.addParameter('v1', tedious.TYPES.DateTime, d2)
		request.addOutputParameter('v4', tedious.TYPES.VarChar, null);
		conn.execSql(request);
	})
}

error message:
'The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect.
Parameter 3 ("@v1"): The supplied value is not a valid instance of data type datetime. Check the source
data for invalid values. An example of an invalid value is data of numeric type with scale greater than
precision.',

Activity

  1. heroboy commented on Jun 13, 2018

    @heroboy
    ContributorAuthor

    I find in DateTime.js,the write value is { days: 43261, threeHundredthsOfSecond: 25920000 }
    2590000 = 24 * 3600 * 300, is one day. Maybe it can not great than this.

  2. heroboy commented on Jun 13, 2018

    @heroboy
    ContributorAuthor

    You should use useUTC: false, to test this code.

  3. arthurschreiber commented on Oct 29, 2019

    @arthurschreiber
    Collaborator

    🎉 This issue has been resolved in version 6.6.1 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions