Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to insert a DateTime exact on milliseconds (interbase)

Status
Not open for further replies.

ExtraD

Programmer
Jul 6, 2005
41
0
0
NL
Hi,

i have the following question.
how do i insert a datetime millisecond exact in interbase?
i know how to insert a normal datetime:
CStr(DateTime.Now.ToString("MM-dd-yyyy hh:mm"))

but how do i insert one with milliseconds?

Many Thanx in advance!!!
 
Hi,

Not sure how to convert it back into a sensible date time, but
Code:
datetime.now.ticks

shows the number of milliseconds (100 nanosecond) intervals that have elapsed since 12:00 A.M., January 1, 0001.

I'm sure someone here can tell you how to convert it back to a date time - in fact the app im programming at the moment will need to do this at some point so I'd like to know how to do it as well :)

Jeff.
 
This works:
...
{
//Create a new DTM object and assign it to the Begining of time
//If you do not want beinging of time, create object with desried time
DateTime dt = new DateTime(0001,01,01,12,00,00,000);

//create long variable to hold the current number of ticks
long ticks = DateTime.Now.Ticks;

//Write out the time - Should equal current DTM
Console.WriteLine(dt.AddTicks(ticks));
Console.ReadLine();
}

Good Luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top