Compare Creation date with Now()

Compare Creation date with Now()

Anonymous
Not applicable
894 Views
2 Replies
Message 1 of 3

Compare Creation date with Now()

Anonymous
Not applicable

I want to make a routine that will check all files in an assembly that have been changed since a user-selected date. I can't get the date to format into a regular number or a string, it seems to stay stuck as a "TimeStamp" format.

 

Does anyone know how I can use a TimeStamp as a Double, or even a string?

 

Thank you

 

Example (simplified)  code:

SyntaxEditor Code Snippet

Dim DateModif = iProperties.Value("Project", "Creation date")
Dim Maintenant As DateTime
Dim TimeText As String
Dim oTime as TimeSpan
Maintenant = Now
oTime = Now().Subtract(DateModif)
MessageBox.Show(DateModif, "iLogic")

The "Now().Subtract(DateModif)" seems to work, as it does not crash or cause any trouble, but I can't use oTime as any knid of variable.

 

Please help, Thanx.

0 Likes
Accepted solutions (1)
895 Views
2 Replies
Replies (2)
Message 2 of 3

Owner2229
Advisor
Advisor
Accepted solution

Hi, how about this?

 

time1 = iProperties.Value("Project", "Creation date")
time2 = Now()
Dim ts As TimeSpan = time2 - time1
Dim elapsedTime As String = String.Format("{0:00} Days, {1:00} Hours, {2:00} Min, {3:00}.{4:00} Sec", ts.Days, ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10)
MsgBox(elapsedTime)
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 3 of 3

Anonymous
Not applicable

Awesome! I don't need that kind of precision, but I took what I wanted out of it. This is definitely going in my bag of tricks. 

 

We sometimes change parts in existing assemblies, and I'm the one who ends up digging in the assembly trying to find what file has changed so I can update the drawing. With this I'll be able to search for the parts modified at a certain date (or timeframe) and pull out a list so I don't forget anything. Of course I'll go for a "Modified date" instead of a "Creation date", but it should still work.

 

Two thumbs up, dude!

0 Likes