question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Need to pass CURRENT_TIMESTAMP with execute()

See original GitHub issue

How can I pass CURRENT_TIMESTAMP when using .execute()? I need the current timestamp with no timezone offset; the data in my DB is stored in local time (not UTC) with no timezone. I can use new Date() and remove the offset, but node-mssql still constructs the date with an offset of +00:00 that looks like this:

2019-02-27 09:14:31.6660000 +00:00

Additionally, I would prefer to use CURRENT_TIMESTAMP so that SQL Server evaluates the date on its own at execution time. Sending a timestamp from JS could potentially cause a slightly incorrect date if there is any delay in executing the stored procedure.

Software versions

  • NodeJS: 10.15.1
  • node-mssql: 4.3.2
  • SQL Server: 2016

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16

github_iconTop GitHub Comments

1reaction
patriksimekcommented, Apr 7, 2019

@GridTrekkor Parameters are here to pass values, not keywords. It just doesn’t feel right to do that.

1reaction
dhensbycommented, Feb 27, 2019

OK - I’d like to wait to hear from @patriksimek about this, but it may be that we need to modify the datetime Type to allow current_timestamp as an allowed value which is then passed through literally…

For now, I suspect it just is not possible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Need to get current timestamp in Java - Stack Overflow
java.util.Date date = new java.util.Date(); System.out.println(new Timestamp(date.getTime()));.
Read more >
How to get current timestamps in Java - Mkyong.com
This article shows few Java examples to get the current date time or timestamp in Java. (Updated with Java 8). Code snippets
Read more >
CURRENT TIMESTAMP special register - IBM
The CURRENT TIMESTAMP (or CURRENT_TIMESTAMP) special register specifies a timestamp that is based on a reading of the time-of-day clock when the SQL...
Read more >
SQL Commands to check current Date and Time (Timestamp ...
This article explores different SQL Commands (functions) to return the current Date and Time (Timestamp) in SQL Server.
Read more >
Passing timestamp as parameter in a procedure — oracle-tech
Hi All, I want to pass timestamp as paramter to a procedure ..when i try to execute it and give time stamp as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found