| Author |
Message |
guitarman fourth grade
Joined: 04 Nov 2005 Posts: 728
|
Posted: Wed Oct 25, 2006 1:43 pm Post subject: need help! How to compare two date Object? |
|
|
Hi guys,
At work i got this problem whereby I need to compare two date function. It is actually an eScript available in Siebel (The package software i'm working on), which is similar to the javascript. I've done something like below:
| Code: |
var myDate1= new Date('2006-09-30');
var myDate2 = new Date('2006-10-30');
if (myDate1 > myDate2) {
//do something
} else {
//do something else
} |
sadly, this does not work properly i.e. sometimes it goes to first if statement and sometimes it goes to else statement. This is very annoying.
I heard of something call JulianDay but i'm not sure if it's workable to use such function.
Any has done something similar to compare two date object?
Greatly appreciate,
|
|
| Back to top |
|
 |
indogo fourth grade
Joined: 03 May 2006 Posts: 223
|
Posted: Thu Oct 26, 2006 6:04 am Post subject: |
|
|
Hmm...is it being treated as a string comparison and because it is internet date format it is back to front.
Is there a command to convert to pure numerical like php date() returns?
Sit back...take a coffee...all will become clear
mike
|
|
| Back to top |
|
 |
guitarman fourth grade
Joined: 04 Nov 2005 Posts: 728
|
Posted: Thu Oct 26, 2006 1:24 pm Post subject: |
|
|
| indogo wrote: |
| Hmm...is it being treated as a string comparison and because it is internet date format it is back to front. |
yes, that could be the reason it doesn't work as expected.
| indogo wrote: |
Is there a command to convert to pure numerical like php date() returns?
|
I just found out about the Date.getTime() function in eScript, Siebel that convert it to a numerial format.
| indogo wrote: |
Sit back...take a coffee...all will become clear
mike |
hey ya! hahah, i took a long break, one day later than i find the solution i.e. to use what you have suggested, mike 
|
|
| Back to top |
|
 |
indogo fourth grade
Joined: 03 May 2006 Posts: 223
|
Posted: Thu Oct 26, 2006 5:08 pm Post subject: |
|
|
Kool...
all these different script languages seem to be getting very similar
well posting the question to find your own answer is often a good technique
have fun
mike
|
|
| Back to top |
|
 |
Duality first grade
Joined: 06 Nov 2006 Posts: 17
|
Posted: Tue Nov 07, 2006 9:14 pm Post subject: |
|
|
The one thing I don't like about Javascript is that every browser treats it differently depending on the code used. I would gladly use it if it didn't have this factor in it.
|
|
| Back to top |
|
 |
web_design first grade
Joined: 04 Jan 2006 Posts: 23 Location: Phnom Penh
|
Posted: Thu Nov 09, 2006 6:32 pm Post subject: |
|
|
It's JavaScript. hahaha
|
|
| Back to top |
|
 |
Singachea fourth grade
Joined: 19 Nov 2005 Posts: 258
|
Posted: Fri Nov 10, 2006 12:15 am Post subject: |
|
|
Actually why do you need to compare those objects in SQL? Why not in scripting or programming languages?
|
|
| Back to top |
|
 |
|