C # .net Datetime value to Integer

I am really new to C # and I had a problem converting DateTime to it. Integer date format. I already have a network, but I did not find the answer.

I want to convert the current date to an integer. Example date "2011-08-11" in the format "yyyy-MM-dd" has an integer value of 734360

+4
source share
4 answers

Pervasive uses days from 1/1/1.

To convert from int to date use

new DateTime(1, 1, 1).AddDays(734360) 

To convert to int using date use

 TimeSpan t = (new DateTime(2011, 08, 11)-new DateTime(1, 1, 1)); int days = (int)t.TotalDays+1; 
+10
source

myDateTime.Ticks will give you a unique representative Int64 value if that is what you need.

+7
source

You can also try:

 DateTime MyDate = new DateTime(); int Year = MyDate.Year; int Month = MyDate.Month; int Day = MyDate.Day; 

if that is what you are looking for.

+3
source
 int calculation; DateTime processDate; calculation = Convert.ToInt32(Convert.ToString(processDate)); 

u can also use this method.

0
source

All Articles