Click here to Skip to main content
15,917,005 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
This code below works already, but only with Filesystem.FileDateTime, and for this i need a file, but it doesnt work when i replace it with a date string even i found out that the datemethod of filedatetime the same is as it will be returned when i write Now.ToString.

WORKS;
VB
If DateDiff("d", FileSystem.FileDateTime("C:\example.ini"), Now) > 15 Then
MsgBox("The Free Version reached the Free Limit of 15 Days") : Else : End If


DOESNT WORK;
VB
If DateDiff("d", 1.5.2012 12.00.00MD, Now) > 15 Then
MsgBox(""): Else : End If


Do i have to declare it as date or as string or did i miss something else?
This is very difficult since to prove the right solution i must wait at least one day. Thanks in advance!

[EDIT]Code tags added - LOSMAC[/EDIT]
Posted
Updated 4-May-12 7:30am
v2

Yes, you have to create date and then do DateDiff.
Some thing like this.

VB
If DateDiff("d", new System.DateTime(2012,5,1,12,0,0), Now) > 15 Then
MsgBox(""): Else : End If
 
Share this answer
 
Comments
Maciej Los 4-May-12 13:32pm    
Good answer. My 5!
And useful link DateDiff function
thams 4-May-12 13:43pm    
Hi, los
forgot to vote?
[no name] 5-May-12 12:53pm    
Thanks dude it works like a charm, i have one more question is the time format 24hours or 12AM/PM format?
DateDiff requires the 2 dates to be DateTime. 1.5.2012 12.00.00MD is not a DateTime, so convert it to one and use it.
 
Share this answer
 
v2
Comments
Maciej Los 4-May-12 13:32pm    
Good answer. My 5!
And useful link DateDiff function

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900