Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
53
rated 0 times [  58] [ 5]  / answers: 1 / hits: 33137  / 10 Years ago, tue, january 13, 2015, 12:00:00

I am having a difficult time checking if one date is less than or equal to another.



Here is my code,



var bftStartDt = input1[0]; //This is a string with value 01-Jul-2007
var bftEndDt = input1[4]; //This is a string with value 01-Jul-1942

var strtDt = new Date(bftStartDt);
var endDt = new Date(bftEndDt);
var flag = 0; // false

if (endDt <= strtDt){
flag = 1; // true
}


It never enters the if statement when it should ? What am I missing here.



Thanks


More From » date

 Answers
23
var strtDt  = new Date(2007-07-01);
var endDt = new Date(1942-07-01);
var flag = 0; // false

if (endDt <= strtDt){
flag = 1; // true
alert(true);
}


It works check out the plunker


[#68218] Sunday, January 11, 2015, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
victorr

Total Points: 193
Total Questions: 86
Total Answers: 105

Location: Pitcairn Islands
Member since Thu, Jun 24, 2021
3 Years ago
victorr questions
Fri, Nov 13, 20, 00:00, 4 Years ago
Sat, Jul 25, 20, 00:00, 4 Years ago
Thu, Jun 11, 20, 00:00, 4 Years ago
;