Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 624859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:14:46+00:00 2026-05-13T19:14:46+00:00

Given a table with a column DueDate, what would be the approximate jQuery code

  • 0

Given a table with a column “DueDate”, what would be the approximate jQuery code for say, setting the backcolor of the table rows based on the value of each DueDate cell with respect to another date?

I am most specifically interested in the pitfalls involving how to properly handle the dates….how to consume a string value explicitly as a date in javascript, do I have to be very strict with the date formatting, etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:14:47+00:00Added an answer on May 13, 2026 at 7:14 pm

    Given that you are able to convert the dates to seconds (or milliseconds) using Date.parse(), you can then use something like this:

    var min = false, max = false;
    
    // Find the minimum and maximum date
    $('tr').each(function() {
        // Acquire a numeric presentation somehow
        var milliseconds = parseInt(Date.parse($(this).find('td.date').html()));
    
        // Determine the min and max
        min = milliseconds < min || !min ? milliseconds : min;
        max = milliseconds > max || !max ? milliseconds : max;
    });
    
    
    $('tr').each(function() {
        // Get the numeric presentation for current row
        var milliseconds = parseInt(Date.parse($(this).find('td.date').html()));
    
        // The relative position of the date, 0 = min date, 1 = max date
        var position = (milliseconds - min) / (max - min);
    
        // Generate color components
        var red   = Math.round(((0 - position) + 1) * 255).toString(16);
        var green = Math.round(position * 255).toString(16);
    
        // Build hex color string
        red     = red.length == 1   ? '0' + red   : red;
        green   = green.length == 1 ? '0' + green : green;
        var hex = '#'+red+green+'00';
    
        // Apply the color
        $(this).find('td').css('background-color', hex);
    });
    

    If it isn’t clear from the code, this snippet will first find the minimum and maximum dates, then color the rows so that the minimum date is red and maximum green.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a table with a datetime column, how do I query for rows where
How would i insert a number of rows into a table given an incremental
Given a table where the first column is seconds past a certain reference point
I have a table that contains records with a column indicates the Date. Given
Given a table with a hierarchyid type column, how do you write a query
Hi Given that I have a table with 2 columns. Table Booking Column Amount-TransactionDate
Given a table name and column name in a pair of variables, can I
Given a table or view with an Integer column is it possible to do
I need to partition a table in PostgreSQL based on a column without sorting
I have a table in which in one of the column I would be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.