The DateTime Ticks property simply returns a long that represents the amount of ticks (100-nanosecond interval) that have passed since january 1, 0001 12:00:00.
using System;
class Program
{
static void Main()
{
DateTime variable = DateTime.Now;
long ticks = variable.Ticks;
Console.WriteLine(ticks);
Console.Read();
}
}
output:633117518171562500
Convery Ticks Back to DateTime
Now that we have converted a DateTime object to a Ticks now we have to learn how to convert is back to a DateTime value.
using System;
class Program
{
static void Main()
{
long ticks = 633117518171562500;
DateTime date = new DateTime(ticks);
Console.WriteLine(date.ToString());
Console.Read();
}
}
Output: 4/9/2007 9:43:37 PM
Subscribe to:
Post Comments (Atom)
Table Partitioning in SQL Server
Table Partitioning in SQL Server – Step by Step Partitioning in SQL Server task is divided into four steps: Create a File Group Add Files ...
-
SELECT T.name AS [TABLE NAME], I.rows AS [ROWCOUNT] FROM sys.tables AS T INNER JOIN sys.sysindexes AS I ...
-
The DateTime Ticks property simply returns a long that represents the amount of ticks (100-nanosecond interval) that have passed since janua...
-
Introduction In Web Programming, the refresh click or postback is the big problem which generally developers face. So in order to avoid...
No comments:
Post a Comment