Solved

Create a fixed current timestamp

Posted on 2014-12-29
7
67 Views
Last Modified: 2015-01-02
Is it possible to create a fixed timestamp from the now function

At present i am using now and then manipulating the date but the result keeps changing as now keeps changing.

Can i take a snapshot of now that remains fixed?
0
Comment
Question by:SweetingA
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 25

Expert Comment

by:Shaun Kline
Comment Utility
You could assign a variable to hold the initial value of Now and then use the variable in place of any other calls to Now.
0
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
Comment Utility
Dim MyDate As Date

MyDate = Now() ' Do you want the date formatted?

blah = MyDate
0
 

Author Comment

by:SweetingA
Comment Utility
I did that already and the variable keeps changing
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
Variables don't change unless you change them somehow like if you run the above code several times.

Please show the code that uses Now().
0
 
LVL 25

Expert Comment

by:Shaun Kline
Comment Utility
Post your code and we can advise.
0
 
LVL 32

Expert Comment

by:it_saige
Comment Utility
Now() may change, but the value in MyDate *does not* change.  Consider the following:
Module Module1
	Private MyDate As Date

	Sub Main()
		MyDate = Now()
		Console.WriteLine("The date variable is: {1}.{0}While the current system time is: {2}", Environment.NewLine, MyDate.ToString("hh:mm:ss tt"), Now().ToString("hh:mm:ss tt"))
		System.Threading.Thread.Sleep(10000)
		Console.WriteLine()
		Console.WriteLine("After sleeping for 10 seconds...")
		Console.WriteLine("The date variable is: {1}.{0}While the current system time is: {2}", Environment.NewLine, MyDate.ToString("hh:mm:ss tt"), Now().ToString("hh:mm:ss tt"))
		Console.ReadLine()
	End Sub
End Module

Open in new window

Produces the following output -Capture.JPG-saige-
0
 
LVL 32

Expert Comment

by:it_saige
Comment Utility
And, because each operation takes a certain amount of time to process.  Once I set the MyDate value as Now() and then produce an output using a new call to Now().  MyDate and Now() actually are not the same value (they are actually milliseconds apart).  To illustrate:
Module Module1
	Private MyDate As Date

	Sub Main()
		MyDate = Now()
		Console.WriteLine("The date variable is: {1}.{0}While the current system time is: {2}{0}Is MyDate equal to Now()? {3}", Environment.NewLine, MyDate.ToString("hh:mm:ss tt"), Now().ToString("hh:mm:ss tt"), MyDate.Equals(Now()))
		System.Threading.Thread.Sleep(10000)
		Console.WriteLine()
		Console.WriteLine("After sleeping for 10 seconds...")
		Console.WriteLine("The date variable is: {1}.{0}While the current system time is: {2}{0}Is MyDate equal to Now()? {3}", Environment.NewLine, MyDate.ToString("hh:mm:ss tt"), Now().ToString("hh:mm:ss tt"), MyDate.Equals(Now()))
		Console.ReadLine()
	End Sub
End Module

Open in new window

Now produces -Capture.JPG-saige-
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now