Date Functions

Although Cartographica isn't awash in great date functionality, mostly owing the the lack of solid date, time, and timezone support in many geospatial data formats, it Column Formulas do have access to the date functionality of Python, which means there are some sophisticated date capabilities available.

Use of date classes

Most of the date and time functions work on datetime objects, which are not usable by Cartographica directly. However, they can be further operated on to retrieve the data stored within them by using day, month, year (and hour, minute, second) accessors.  For example will provide the integer day of the month.

Dates can also be converted into strings by using the strftime() method on a datetime object.  For example,"%Y-%m-%d") will provide the current date in "YYYY-MM-DD" form, or 2020-01-23 if it were the date this page was being written.

datetime's date as a datetime object

datetime datetime.utcnow()

Today's date and time in UTC as a datetime object
str .strftime(str format)String representation of the requested date
int .weekday()Return the day of the week as an integer (0=Sunday, 1=Monday, etc.)
str .ctime()Return the date and time as a string in human-readable format.
datetime strptime(str date_string, str format)Create a new datetime object from the date_string using the requested format. 

Date Format Strings

The Python documentation details the date format, however the strings used for strftime and strptime are built from the following directives:

%dDay of the month as a zero-padded decimal number01, 02, ..., 31
%mMonth of the year as a zero-padded number01, 02, ..., 12
%y2-digit year as a zero-padded number00, 01, ... 99
%Y4-digit year as a zero-padded number0000, ..., 2020, ...., 9999
%H24-hour clock Hour as a zero-padded number00, 01, ..., 23
%I12-hour clock Hour as a zero-padded number00, 01, ..., 12
%pAM/PM (or local equivalent)AM, PM
%MMinute as a zero-padded number00, 01, ..., 59
%S Second as a zero-padded number00, 01, ..., 59

Common Examples

StringOutput Example
%m/%d/%y %H:%M:%S12/31/19 23:59:59