This is the VBScript code that isn't working....
---
dcreated = fileName.DateCreated
ddiff = DateDiff("d", Now, dcreated)
If ddiff < 8 Then
'Blah
End if
---
I create a variable ddiff... this variable contains the nr of days from
the created date until today. When I print the variable ddiff, it
contains the right number.

But when I use it in the If statement (<8) then --- ALL --- the ddiff
values, also the ones that are bigger than 7, pass this statement!! I
checked the contents of the variable ddiff by printing them, and the
are correct. It seems that the If statement is nog working...

What to do?

Regards,

Tom

RE: problems with vbscript if statement by Chuck

Chuck
Wed Jan 25 15:31:02 CST 2006

Just swap the order of arguments to DateDiff("d", dcreated, Now)

> ddiff = DateDiff("d", Now, dcreated)
This is always going to return a negative number unless the file creation
date is in the future.

"tvdbroek@hotmail.com" wrote:

> This is the VBScript code that isn't working....
> ---
> dcreated = fileName.DateCreated
> ddiff = DateDiff("d", Now, dcreated)
> If ddiff < 8 Then
> 'Blah
> End if
> ---
> I create a variable ddiff... this variable contains the nr of days from
> the created date until today. When I print the variable ddiff, it
> contains the right number.
>
> But when I use it in the If statement (<8) then --- ALL --- the ddiff
> values, also the ones that are bigger than 7, pass this statement!! I
> checked the contents of the variable ddiff by printing them, and the
> are correct. It seems that the If statement is nog working...
>
> What to do?
>
> Regards,
>
> Tom
>
>