Maptitude GISDK Help |
A DateTime compound variable can be used to store a date and/or a time; for more information, see Compound Variables. You can use Date, Time, and DateTime as field types in fixed-format binary tables; for more information, see CreateTable().
You can use these functions with DateTime compound variables:
GISDK Function |
Summary |
Creates a DateTime compound variable with just a date |
|
Creates a DateTime compound variable |
|
Creates a DateTime compound variable with just a time |
|
Formats a DateTime compound variable |
|
Parses a string to create a DateTime compound variable |
The following methods add a time period to a DateTime compound variable:
datetime.AddYears(int years)
datetime.AddMonths(int months)
datetime.AddDays(int days)
datetime.AddHours(int hours)
datetime.AddMinutes(int minutes)
datetime.AddSeconds(int seconds)
datetime.AddMilliseconds(int milliseconds)
In each case, the method adds to the compound variable an integer value for the component of the date or time, and returns a new DateTime value. You can pass a negative value to subtract the specified component. The methods can be chained together to modify multiple components. For example:
dt = CreateDateTime(13, 8, 2014, 10, 46, 31, 0)
//Aug 13 2014, 10:46:31 AM
new_dt = dt.AddHours(2).AddMinutes(10)
//Aug 13 2014, 12:56:31 PM
The following methods compute the elapsed time period between two DateTime compound variables:
datetime.DaysSince(DateTime date)
datetime.HoursSince(DateTime date)
datetime.MinutesSince(DateTime date)
datetime.SecondsSince(DateTime date)
datetime.MillisecondsSince(DateTime date)
Each method takes a DateTime parameter, subtracts it from the current datetime, and returns the elapsed time as a signed integer. If the given date is earlier than the current DateTime, a negative value is returned. For example:
dt = CreateDateTime(13, 8, 2014, 10, 46, 31, 0)
//Aug 13 2014, 10:46:31 AM
new_dt = dt.AddHours(24).AddMinutes(10)
//8/14/2014 10:56:31 AM
days = new_dt.DaysSince(dt)
// 1.006944
negdays = dt.DaysSince(new_dt)
// -1.006944
Before the DateTime compound variable was introduced, dates and time were handled with strings. Here are the older GISDK functions that deal with dates and time:
GISDK Function |
Summary |
Converts a date to a day of the week |
|
Determines the current date and time according to the system clock |
|
Returns a new date given an original date and an offset in days |
|
Returns the date of the next occurrence of a given day |
©2025 Caliper Corporation | www.caliper.com |