Achieve identical outcomes using an Oracle SQL Query as you would with the JS Date.now() method

Is there a way to replicate the millisecond value obtained from using the date.now() method in JavaScript through an SQL select statement?

I believe this SQL query could be a starting point:

select (strftime('%s','now') || substr(strftime('%f', 'now'),4,3)) from dual;

However, I am having difficulties formatting it to match the result mentioned above.

Answer №1

Here is the SQL query:

SQL> SELECT     (CAST (SYSTIMESTAMP AS DATE) - DATE '1970-01-01')
  2           * 24
  3           * 60
  4           * 60
  5           * 1000
  6         + MOD (EXTRACT (SECOND FROM SYSTIMESTAMP), 1) * 1000 result
  7    FROM DUAL;

          RESULT
----------------
   1629124489718

SQL>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

JavaScript timekeepers and Ajax polling/scheduling

After looking into various methods like Comet and Long-Polling, I'm searching for a simpler way to push basic ajax updates to the browser. I've come across the idea of using Javascript timers to make Ajax calls at specific intervals. Is this app ...

Displaying content on a click event in AngularJS

I am facing an issue with the ng-show directive not working as expected when a user clicks on an icon. The desired behavior is that the parent div should initially display content, but when the play icon is clicked, the contents of the div should become ...

The step-by-step guide to testing an Angular promise using Jasmine

An issue arises when attempting to test the code below using Jasmine, as the console.log in `then` is never called. The question remains: is this problem related to Angular or Jasmine? describe("angular test", function() { var $q; ...

I need help figuring out the right way to define the scope for ng-model within a directive

I found a straightforward directive to automate sliders: app.directive('slider', function() { return { restrict: 'AE', link: function(scope, element, attrs) { element.slider({ value: scop ...

Tips for effectively utilizing an if/else structure to animate fresh content from the right while smoothly removing old content by sliding it to the left

document.getElementById("button1").addEventListener("click", mouseOver1); function mouseOver1(){ document.getElementById("button1").style.color = "red"; } document.getElementById("button2").addEventListener("click", mouseOver); function mous ...

Execute Function on Double-Click with Flot.js

Is there a way to run a function when the mouse double-clicks while using flot? Currently, I am only able to trap the single click with the following code: $(graph).bind('plotclick', function(event, pos, item) { if (item) { .... ...

The issue arises when jQuery stops functioning properly following the second ajax call

I'm encountering an issue with my ajax request in asp.net mvc. It works fine for the first and second time, but then it redirects to a page instead of fetching the page via ajax. Below is the code snippet for my partial page: <script> var ...

Reply to changes in the window size *prior to* adjusting the layout

Take a look at the "pixel pipeline" concept illustrated with a vibrant diagram on this page. I am currently working on resizing an element (let's say, a span) dynamically when the browser window is resized. I have implemented this using window.onresi ...

The system is currently unable to find the specified element

I am facing an issue trying to locate a button that is defined under a specific class using XPATH. The error message "Unable to locate element" keeps popping up. Here are the details of the class: <div class="aui-button-holder inputBtn" id="aui_3_4_0_1 ...

How do I set up a recurring task every two minutes using selenium webdriver in JavaScript?

I need to test my website by logging in and clicking the refresh button every 2 minutes without closing the browser window. Here is a simplified version of my code: var webdriver = require('selenium-webdriver'); var driver = new webdriver.Builde ...

specific css styles only for Safari and Internet Explorer

Imagine a scenario where I have a div with the class 'x': <div class = 'x' /> This div has some CSS properties and what's interesting is that it appears differently in Safari and the latest version of IE compared to other ...

Utilizing displacement mapping in three.js

Currently, I am using a grayscale image as a bump map for my model. The model consists of an .obj file paired with the corresponding .mtl file for UV mapping. Below is the code snippet that I am utilizing: // Load material file var mtlLoader = new THREE.M ...

Styling hyperlinks upon exporting an HTML table to Excel

I am trying to export an HTML table to Excel using JavaScript by following the instructions provided in Export HTML table to Excel its downloading table contents to the Excel. However, I have encountered an issue where one of the columns in my table conta ...

The Async/Await feature does not truly wait within a while loop

As I neared the completion of my project, I realized that the final component would require the use of Async, Await, and Promise to ensure that the program waits for an API call to finish before proceeding. Despite my understanding that there is no true "s ...

Is it possible to alter the page color using radio buttons and Vue.js?

How can I implement a feature to allow users to change the page color using radio buttons in Vue.js? This is what I have so far: JavaScript var theme = new Vue({ el: '#theme', data: { picked: '' } }) HTML <div ...

Troubles encountered while converting multidimensional JSON array into multiple PHP arrays

Having recently delved into the realms of JavaScript and PHP, I have come across various resources for assistance. However, I seem to be encountering a slight hiccup with my JSON string. Personally, I find it quite straightforward. The contents of the str ...

Is there a way to calculate the total of three input values and display it within a span using either JavaScript or jQuery?

I have a unique challenge where I need to only deal with positive values as input. var input = $('[name="1"],[name="2"],[name="3"]'), input1 = $('[name="1"]'), input2 = $('[name="2"]'), input3 = $('[name=" ...

Is it possible to find a more efficient approach than calling setState just once within useEffect?

In my react application, I find myself using this particular pattern frequently: export default function Profile() { const [username, setUsername] = React.useState<string | null>(null); React.useEffect(()=>{ fetch(`/api/userprofil ...

"The Effectiveness of Utilizing the For..in Loop for Iterating Over Arrays and

Can anyone help me understand why I encountered an error message when trying to loop over an array using a for..in loop to display the index of each item? I'm looking for advice on how this process actually works. Thanks! ...

Prevent callback function execution in JavaScript

Users have the ability to select a month by clicking +1 month or -1 month. Each click triggers a loop based on the number of days in the chosen month. Within the loop, a function is called to fetch data through an $http request. The issue at hand is as ...