Skip to main content

Hello Community,

i am working on a script which should look a 2 sets of dates and then it should know what to do. Right now i have made a script which makes it possible for it to understand whether it is less than 30 days ahead, more than 30 days ahead, but i cant seem to figure out how to make it understand when the date is older than the current date

 

my current script looks like this:

'***************************************************************************************************************************
emreadscreen exampleDate3,5,1,71
emreadscreen exampleDate4,5,17,30
emreadscreen status48,5,17,30

ThisYear = Year(Now)
betwDates = DateDiff("d", exampleDate4, exampleDate3)


if betwDates > 30 then
emsetcursor 7,51
emsendkey "-"
emsetcursor 7,52
emsendkey ThisYear

else

emsetcursor 7,51

emsendkey "-"

emsetcursor 7,52

emsendkey Thisyear 1 

 

'****************************************************************************************************************************

 

 

the problem for me is that no matter how i make rumba calculate the difference between the two dates it always comes back as a positive number and it doesn't understand that e.g. 01-04 is older than 01-08

 

  you have helped me before, hopefully you could help me again.


#Rumba

Hello Community,

i am working on a script which should look a 2 sets of dates and then it should know what to do. Right now i have made a script which makes it possible for it to understand whether it is less than 30 days ahead, more than 30 days ahead, but i cant seem to figure out how to make it understand when the date is older than the current date

 

my current script looks like this:

'***************************************************************************************************************************
emreadscreen exampleDate3,5,1,71
emreadscreen exampleDate4,5,17,30
emreadscreen status48,5,17,30

ThisYear = Year(Now)
betwDates = DateDiff("d", exampleDate4, exampleDate3)


if betwDates > 30 then
emsetcursor 7,51
emsendkey "-"
emsetcursor 7,52
emsendkey ThisYear

else

emsetcursor 7,51

emsendkey "-"

emsetcursor 7,52

emsendkey Thisyear 1 

 

'****************************************************************************************************************************

 

 

the problem for me is that no matter how i make rumba calculate the difference between the two dates it always comes back as a positive number and it doesn't understand that e.g. 01-04 is older than 01-08

 

  you have helped me before, hopefully you could help me again.


#Rumba

Hi,
may the CDate Function is of help.
CDate converts any valid expression to a Date variable.

example:

Sub Main
 Dim MyDate1, MyDate2
 MyDate1 = "01.04.1975"   ' define date with - format
 MyDate2 = "01-08-75"       'define date with . format


 If CDate(MyDate1) < CDate(MyDate2) then
   MsgBox ("older")
 Else
   MsgBox ("younger")
 End If

End Sub