Sign in to follow this  
Followers 0
Champak

If with date function not working

4 posts in this topic

Can someone tell me why the following isn't working?

If _DateDiff( 'd',$Full_List[$Position][5],_NowCalc()) <= 2 Then 
        $PriceDate = "Price is recent and most likely still in effect."
        GUICtrlSetColor($Label_Date,0x00EC00)
    ElseIf _DateDiff( 'd',$Full_List[$Position][5],_NowCalc()) >= 3 And _DateDiff( 'd',$Full_List[$Position][5],_NowCalc()) <= 4 Then
        $PriceDate = "Price is 3 to 4 days old."
        GUICtrlSetColor($Label_Date,0xFF860D)
    ElseIf _DateDiff( 'd',$Full_List[$Position][5],_NowCalc()) > 5 Then 
        $PriceDate = "Price is older than 5 days."
        GUICtrlSetColor($Label_Date,0xFF0000)
    EndIf

It only seems to see the first "IF" function no matter what the date difference is. The difference is always "0". If I put the consolewrite inside the first "IF", I can see that the date is hitting ranges where they should actually be going into the other "elseif" functions, but the calculations difference always come back as "0".

What am I not seeing?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The only thing I can think of is maybe the format of your timestamp is incorrect. What date for example is stored in your array?

msgbox(0,"",$Full_List[$Position][5])

I think it has to look like this. "YYYY/MM/DD hh:mm:ss"

Edited by spudw2k

Share this post


Link to post
Share on other sites

Can someone tell me why the following isn't working?

If _DateDiff( 'd',$Full_List[$Position][5],_NowCalc()) <= 2 Then 
        $PriceDate = "Price is recent and most likely still in effect."
        GUICtrlSetColor($Label_Date,0x00EC00)
    ElseIf _DateDiff( 'd',$Full_List[$Position][5],_NowCalc()) >= 3 And _DateDiff( 'd',$Full_List[$Position][5],_NowCalc()) <= 4 Then
        $PriceDate = "Price is 3 to 4 days old."
        GUICtrlSetColor($Label_Date,0xFF860D)
    ElseIf _DateDiff( 'd',$Full_List[$Position][5],_NowCalc()) > 5 Then 
        $PriceDate = "Price is older than 5 days."
        GUICtrlSetColor($Label_Date,0xFF0000)
    EndIf

It only seems to see the first "IF" function no matter what the date difference is. The difference is always "0". If I put the consolewrite inside the first "IF", I can see that the date is hitting ranges where they should actually be going into the other "elseif" functions, but the calculations difference always come back as "0".

What am I not seeing?

Have you done a verification of the data being read from the array? If so, can you post a sample of the output to help determine if it's perhaps a data structure validation issue?

Ex:

ConsoleWrite($Full_List[$Position][5])

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

It was the format, I forgot I changed the original format before I initially put it in the array. Thanks for the heads up.

Edited by Champak

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0