Results 1 to 17 of 17
 05052008, 04:54 AM #1Member
 Join Date
 Nov 2007
 Posts
 12
 Rep Power
 0
 05052008, 05:03 AM #2
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,370
 Blog Entries
 1
 Rep Power
 22
Did you Goole it. There should be some mathematical way to find it.
 05052008, 05:08 AM #3Member
 Join Date
 Nov 2007
 Posts
 12
 Rep Power
 0
yes i did and cudnt find anything
 05052008, 05:23 AM #4
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,370
 Blog Entries
 1
 Rep Power
 22
Ok, here is a way.
Java Code:N = d + 2m + [3(m+1)/5] + y + [y/4]  [y/100] + [y/400] + 2
m  moth id(from 1 to 12 respectively)
y  year
Do the calculations and find the N. Keep in mind that to drop the remainder in each [] and only get the whole number. Don't rounding off numbers. Then divide the N by 7. Remainder give the answer, day of the week.
0  Saturday
1  Sunday
2  Monday
3  Tuesday and so on.
Try it and see.
 05052008, 05:41 AM #5
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,370
 Blog Entries
 1
 Rep Power
 22
Ah, made a mistake in my explanation. Here is an example for today(5/5/2008)
Java Code:N = 5 + 2(5) + [3(6)/5] + 2008 + [2008/4]  [2008/100] + [2008/400] + 2 N = 5 + 10 + 3 + 2008 + 502  20 + 5 + 2 N = 2515
d is not the number of days of the month. Days spending up to date which we want to processing.
Did you get it?
 05052008, 06:11 AM #6Member
 Join Date
 Nov 2007
 Posts
 12
 Rep Power
 0
im trying to write in servlet and get in jsp
Last edited by veena; 05052008 at 02:40 PM.
 05052008, 06:13 AM #7
The way Eranga explain it is correct. except you have to account for leap years. which you do with an array I forget the exact table.
My IP address is 127.0.0.1
 05052008, 06:19 AM #8
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,370
 Blog Entries
 1
 Rep Power
 22
 05052008, 06:24 AM #9Member
 Join Date
 Nov 2007
 Posts
 12
 Rep Power
 0
hey Eranga
when u add up N=2501
 05052008, 06:33 AM #10
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,370
 Blog Entries
 1
 Rep Power
 22
Is it.
Java Code:N = 1 + 2(1) + [3(2)/5] + 2008 + [2008/4]  [2008/100] + [2008/400] + 2 N = 1 + 2 + 1 + 2008 + 502  20 + 5 + 2 N = 5 + 2008 + 502  20 + 7 N = 2510  20 + 12 N = 2502
 05052008, 06:42 AM #11Member
 Join Date
 Nov 2007
 Posts
 12
 Rep Power
 0
let me try again
Last edited by veena; 05052008 at 02:41 PM.
 05052008, 06:59 AM #12
 05052008, 07:00 AM #13
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,370
 Blog Entries
 1
 Rep Power
 22
Go it. I've miss a very important rule there. Really sorry about. Still I remembering this and let you know, because I do those things few years back when I'm in the university for maths.
You have to use numbers 13 and 14 for the months of January and February, with the previous year. In our discussion,
1/1/2008 should be 1/13/2007.
Lets try it.
Java Code:N = 1 + 2(13) + [3(14)/5] + 2007 + [2007/4]  [2007/100] + [2007/400] + 2 N = 1 + 26 + 8 + 2007 + 501  20 + 5 + 2 N = 2530
Lets do another example, for 20/2/2008. So the date should be 20/14/2007
Java Code:N = 20 + 2(14) + [3(15)/5] + 2007 + [2007/4]  [2007/100] + [2007/400] + 2 N = 20 + 28 + 9 + 2007 + 501  20 + 5 + 2 N = 2552
Keep in mind that, rule only valid for January and February.
 05052008, 07:15 AM #14Member
 Join Date
 Nov 2007
 Posts
 12
 Rep Power
 0
yep i got it and did in servlet
when i was searching i got the same formula
any ways thnks very much
its a nice formula thoughLast edited by veena; 05052008 at 02:41 PM.
 05052008, 07:15 AM #15
I think you can just use the Gregorian calendar I think also.
My IP address is 127.0.0.1
 05052008, 08:48 AM #16
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,370
 Blog Entries
 1
 Rep Power
 22
No matter what calender you used, my formula is working. We have used in few projects that formula, when I'm in the University.
 05062008, 05:03 AM #17
 Join Date
 Jul 2007
 Location
 Colombo, Sri Lanka
 Posts
 11,370
 Blog Entries
 1
 Rep Power
 22
Hey veena, no need to edit your post time to time. If you expecting the answer in different approaches please let it to others. Because later someone read your thread, really confused. :)
Similar Threads

Month and year program code!!!!HELP PLEASE!!!
By chitwood in forum New To JavaReplies: 4Last Post: 10132010, 01:21 PM 
calendar
By John in forum SWT / JFaceReplies: 12Last Post: 08072008, 10:54 PM 
[SOLVED] How to check what type of value entered in text field
By Renegade85 in forum New To JavaReplies: 2Last Post: 04282008, 10:26 AM 
Merry Christmas and happy New year
By rgbosque in forum Forum LobbyReplies: 3Last Post: 12312007, 03:44 AM 
Web calendar
By Daniel in forum Enterprise JavaBeans (EJB)Replies: 1Last Post: 06272007, 05:36 PM
Bookmarks