Choose the data from the initial entry to the second entry within the database

I am currently working on a project that requires me to retrieve dates from a database. The goal is to replace outdated dates with newer ones as they pass.

Unfortunately, I am unsure how to achieve this and would greatly appreciate any assistance.

It seems like the current approach is not yielding the desired results.

 function Load() {
        var sql = "SELECT TijdVan, ID_RECORD FROM pixiocompanys WHERE TijdVan >= CURRENT_TIMESTAMP() ORDER BY TijdTot" ;

        var result = sqlUtil.selectSql(sql, {} , 'default');

            if (result.length === 0 ){
                return;
            }
                var times = getTimes(); 
                var d = new Date();
                var TV = times[0].TijdVan;
                var TT = times[0].TijdTot;
            if( d > TV ){

                var sql = "SELECT TijdVan , ID_RECORD FROM pixiocompanys" ;

            }
        }

Answer №1

When working with MySql, to retrieve the row containing the next closest date, you can utilize the LIMIT clause:

SELECT 
  StartTime, 
  RECORD_ID 
FROM companyPixios 
WHERE StartTime >= CURRENT_TIMESTAMP() 
ORDER BY EndTime
LIMIT 1

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

Tips for verifying g-captcha-response authenticity

When referring to the Google reCAPTCHA documentation, it mentioned: URL: https://www.google.com/recaptcha/api/siteverify METHOD: POST POST Parameter Description secret - Required. The shared key between your site and reCAPTCHA. The response is expecte ...

Is there a way for me to incorporate a feature that verifies whether an email address is already registered before allowing the person to sign up?

I am currently working with Node.js, express.js, mongoose, and pug to develop a registration/login system. I have successfully stored the name and email in a mongoose database with specified schema for these fields. The data is sent from a pug page via a p ...

Experiencing difficulties with extracting information from mySQL for my web development assignment

I am currently working on a personal project to enhance my skills in web and full-stack development by recreating the NYT Connections game. As part of this project, I have developed a database.js file using node.js which successfully connects to a local da ...

Bootstrap 5 - centering "padding" both internally and externally within the accordion

Need help aligning three Boostrap 5 grids: Header outside of accordion Overview in accordion header Details in accordion body The accordion header has margins and padding on the left and right, and the collapse icon also occupies some space. I want the ...

Creating personalized functions in Object.prototype using TypeScript

My current situation involves the following code snippet: Object.prototype.custom = function() { return this } Everything runs smoothly in JavaScript, however when I transfer it to TypeScript, an error surfaces: Property 'custom' does not ex ...

Populating Dropdown list with values based on input provided in Textbox

Can you assist me in finding the solution to this issue? I have a TextBox and a DropDown list. For example, if I type "Anu" into the textbox, I want it to populate the dropdown list based on the text entered. How can I achieve this? I am working with vb. ...

De-duplication in BigQuery with two columns serving as a unique identifier

We heavily rely on BigQuery for our data processing needs, and currently we have two tables that are being updated independently by different processes. The challenge we face is the lack of a unique identifier for these tables, making it difficult to combi ...

"Adding an active class to a link based on the current page and locale: A step-by-step

Looking to add an active class to the subheader menu on the active page, but facing issues when changing the locale in the link. While it works for links like my-site/my-page, it doesn't work for links like my-site/fr/my-page. Utilizing Storyblok head ...

Display the div only when the time variable reaches zero

I want to display a div when the difference between the time imported from the database and the current time is 0. How can I achieve this? Here is the code snippet: while ($row = mysqli_fetch_array($result)) { echo "<div class='alert' id= ...

Changing SQL XML CASE clause to SQL JSON

Looking for help in converting a SQL query that includes an xmlelement with a case statement into JSON format. case when db_field1 = '1' then xmlelement(name "value", 'response1') when db_field2 - '2& ...

What is the best way to show the current value of a checkbox element in the future?

I want to add multiple checkboxes using this method: $(".btn-sample").on("click", function() { $(".container").append( '<input class="check-sample" type="checkbox" value="'+check_value+'"/>' ); }); The issue I' ...

Executing a Hive Distinct Query tends to slow down significantly as the number of files in the database

My Table Structure - I ran the following command in Hive: hive> desc table1; OK col1 string col2 string col3 string col4 bigint col5 string Time taken: 0.454 seconds, Fetched: 5 row(s); File Count Investigation - To find out the number of underlying ...

Achieve sum calculations by categorizing a set in Meteor

I have a dataset containing fields named: number, a, b, c. My goal is to split the dataset into three groups based on the value of the number field, and calculate the total sums of a, b, and c for each group. Currently, I achieved this using the followin ...

Refining a Snowflake SQL query with filters

I'm currently exploring different subquery approaches to extract a specific value from a document by matching it with another value across multiple documents. I can run a query, but the method is not scalable for dynamic data. Consider the dataset bel ...

Looking for guidance on JavaScript - Implementing a different font family for each div element

I need help with customizing the font family for each individual post on my website. Currently, I am able to assign a cursive font to all posts within a class, but I would like each post to have its own unique font. Since I am doing this on load, I am fa ...

Text box size in user input not adapting on mobile devices

Website: Visit the Cutter Travel Calculator here I've encountered an issue with my user input text boxes on mobile. Despite setting their width using the formidable forms plugin, the size adjustment doesn't seem to apply when viewed on mobile de ...

External UI library for AngularJS

Exploring the realm of animations using Angular and Masonry (UI library) has been quite a journey. I've encountered an issue where animating an element located outside the ng-view works perfectly fine, but the same animation doesn't seem to work ...

Replace all occurrences of $regex in Node.js with the json data format

Here is a JSON example var json= { name: { '$regex': /^Amer$/i }, 'countries.name': { '$regex': /^UNited states$/i } } I am looking to reformat it using either lodash or string/json replace method to achieve the following st ...

Arranging HTML elements using JavaScript or jQuery

Something seems off. The sorting doesn't work as expected. Check out the JavaScript code below: function sortDescending(a, b) { var date1 = $(a).data('date'); var date2 = $(b).data('date'); return date1 > date2; } ...

When trying to use routes with the .map() function, it does not seem

I am currently working on developing a multi-page web application using react-router-dom. However, I have encountered an issue with the user list page (userlist.js) where the data inside the .map() function is not being returned. Interestingly, the code pr ...