DateTime fields in SQLite

From what I’ve read on the forum SQLite for ChipworkX doesn’t support the DateTime field. Is this accurate and if so are there intentions to add support for it?

It is accurate. You can store it as strings.

DateTime has a Ticks property - This is stored as a long (64bit integer) and can represent dates from DateTime.MinValue to DateTime.MaxValue with 100ns accuracy.

I can only assume that both the ticks property and the constructor which takes a number of ticks is in NETMF.

Edit: I checked and Ticks is available in NETMF.

I made a timestamp myself:


public static int dateToUnixTimestamp(DateTime date) {
  DateTime referenceDate = new DateTime(1970, 1, 1, 0, 0, 0, 0);  
  TimeSpan ts = new TimeSpan(date.Ticks - referenceDate.Ticks);  
  return (int)(ts.Ticks/TimeSpan.TicksPerSecond);
}


public static DateTime unixTimestampToDate(int timestamp) {
  DateTime referenceDate = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  referenceDate = referenceDate.AddSeconds(timestamp);
  return referenceDate;
}

@ anm - code tags, please :slight_smile:

ooops - did I forget them? :o

There was an error in the code - I just corrected it…