FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
need help! How to compare two date Object?

 
Post new topic   Reply to topic    Cambodia eXPlore Forum Index -> Client - Server Side Development
Author Message
guitarman
fourth grade


Joined: 04 Nov 2005
Posts: 728

PostPosted: Wed Oct 25, 2006 1:43 pm    Post subject: need help! How to compare two date Object? Reply with quote

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

PostPosted: Thu Oct 26, 2006 6:04 am    Post subject: Reply with quote



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 Very Happy

mike

Back to top
guitarman
fourth grade


Joined: 04 Nov 2005
Posts: 728

PostPosted: Thu Oct 26, 2006 1:24 pm    Post subject: Reply with quote

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 Very Happy
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 Rolling Eyes

Back to top
indogo
fourth grade


Joined: 03 May 2006
Posts: 223

PostPosted: Thu Oct 26, 2006 5:08 pm    Post subject: Reply with quote

Kool...

all these different script languages seem to be getting very similar Very Happy

well posting the question to find your own answer is often a good technique Wink

have fun

mike

Back to top
Duality
first grade


Joined: 06 Nov 2006
Posts: 17

PostPosted: Tue Nov 07, 2006 9:14 pm    Post subject: Reply with quote

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

PostPosted: Thu Nov 09, 2006 6:32 pm    Post subject: Reply with quote

It's JavaScript. hahaha

Back to top
Singachea
fourth grade


Joined: 19 Nov 2005
Posts: 258

PostPosted: Fri Nov 10, 2006 12:15 am    Post subject: Reply with quote

Actually why do you need to compare those objects in SQL? Why not in scripting or programming languages?

Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cambodia eXPlore Forum Index -> Client - Server Side Development All times are GMT + 8 Hours
Page 1 of 1



by phpBB