Question : Convert float to date

Hi,

I'm trying to convert a float to a date.

How do I do this?

I found a function in Python, but I don't know Python, only C#.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
def float2date(date):
  """Convert a float to a string containig a date"""  
  date = int(date)  
  year = 1900 + (date / 10000)  
  month = (date % 10000) / 100  
  day = date % 100  
  return '%04d%02d%02d' % (year, month, day)  
   
def float2time(time):  
  """Convert a float to a string containig a time"""  
time = int(time)  
hour = time / 10000  
min = (time % 10000) / 100  
return '%02d%02d' % (hour, min)

Answer : Convert float to date

DateTime double2date(double d) {
  return new DateTime(1900,1,1).AddDays(d);
}

This gives better precision.
Random Solutions  
 
programming4us programming4us