VERIFIED SOLUTION i
X

How to enter values for Date/Time data types in a browser or Table>update column within MapInfo Pro

UPDATED: April 14, 2017


There are various ways to specify a DateTime value.

1.  There are several functions which explicitly return a DateTime value such as NumberToDateTime and StringToDateTime.

To simplify things for customers, it is allowable to enter values as numbers or strings as well.  Then, MapInfo automatically converts the string or number to DateTime values when those values are assigned to a DateTime field in a table or a DateTime variable in MapBasic.

When that conversion is performed, numbers are converted just as the NumberToDateTime function would and strings as the StringToDateTime function would.  A sequence of digits will be treated as a number if there are no quotes and as a string if it is contained within quotes.

To add to the confusion, a sequence of 17 digits can also be used to represent a DateTime: the 4 for the year, two each for the month, day, hour, minutes, and seconds, and three for the milliseconds. That sequence can be entered as a string or a number.

However if fewer than the full 17 digits are entered, a string versus a number would be interpreted differently. One way to think of it would be that the string would be "padded" on the right with zeroes to get the full 17 digits and a number would be padded on the left.

For example, "20150909" would be evaluated as the string "20150909000000000"
And a value of 20150909 would be evaluated as the number 00000000020150909.

2. When entering data into a DateTime field directly into a cell of the Browser or the Info Tool, it is assumed that the value is a string so that users are not required to put quotes around the value.  We assume string because it is the more natural way to enter a DateTime, especially if date and time separators are used (e.g. '/' and ':', respectively, in some locales). However, in the Table>Update Column dialog, string values are always required to have quotes because the context is less clear.

Downloads

  • No Downloads