?
Solved

Convert SQL date to Javascript date to compare

Posted on 2008-11-18
1
Medium Priority
?
2,047 Views
Last Modified: 2012-05-05
I need to convert a date from SQL Server in the following format to Javascript like below

var createddate = 'Sun Nov 9 00:00:00 CST 2008';

var dteNow = new Date();
sMonth = (dteNow.getMonth()+1);
sDay = (dteNow.getDate() - 7);
sYear = dteNow.getYear();
sHours = dteNow.getHours();
sDayThisWeek = sMonth + "" + sDay + "" + sYear;
sActDate = sMonth + "/" + sDay + "/" + sYear;


so I can compare using this:

if (createddate < dteActDate) {
      alert("YES");
}

How do I do this?
0
Comment
Question by:saturation
1 Comment
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 22990334
try:

var createddate = 'Sun Nov 9 00:00:00 CST 2008';
createddate = new Date( Date.parse(createddate) );
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question