This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Weeks comparison Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Weeks comparison" Watch "Weeks comparison" New topic
Author

Weeks comparison

Asheesh Nehra
Ranch Hand

Joined: Jun 25, 2009
Posts: 35
I want to compare two dates if these dates are of same week, how can i do it in javascript any HELP.!!!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
sounds like you want to use the Date Object

Eric
Asheesh Nehra
Ranch Hand

Joined: Jun 25, 2009
Posts: 35
Thanks for your reply, My problem is that I have to compare two dates and determine if they are of the same week. here is no method which take parameter date and return week of the year.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Than build one. Get the day of the week for the first day. [S,M,T,W,T,F,S] subtract the number of days to get the start of the week. See if the other date is greater than the start date. If it is, add seven days and see if it is less than or equal to this new date. If it is, you know it is in the range of the week.

Other option is you take your two days and make them both go to the first day of the week. See if they are the same day. [probably a simpler solution!]

Eric
 
 
subject: Weeks comparison
 
Similar Threads
How to calculate difference between two dates in months
Get date List between two dates in mysql
comparing dates
difference between two dates
URGENT !