Set Date Window() statement - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Displays a date window that converts two-digit input into four-digit years. It also allows you to change the default to one that best suits your data. You can issue this statement from the MapBasic window in MapInfo Pro.

Syntax

Set Date Window { nYear | Off }

nYear is a SmallInt from 0 to 99 that specifies the year above which is assigned to the previous century (19xx) and below which is assigned to the next century (20xx). (For example, by specifying nYear as 70, a 2-digit year of 70 and above corresponds to the years 1970-1999, and a 2-digit year of 69 and below correspond to the years 2000-2069.)

Off turns date windowing off. Two-digit years will be converted to the current century (based on system time/calendar settings).

Description

From the MapBasic window, the session setting will be initialized from the Preference setting and updated when the preference is changed. Running the Set Date Window statement from the MapBasic window will change the behavior of input, but will not update the System Preference that is saved when MapInfo Pro exits.

The session setting is affected by running Set Date Window in the MapBasic window, in any workspace file including STARTUP.WOR, and any integrated mapping application that runs the command via the MapInfo Pro application interface.

When the Set Date Window command is run from within a MapBasic program (also as Run Command statement) only the program's local context is updated with the new setting. The session and preference settings remain unchanged. The program's local context is initialized from the session setting. This is similar to how number and date formatting works. They are set/accessed per program if a program is running, otherwise they set/access global settings.

Enter a number from 0-99. The number you enter displays in the statements below the prompt that indicate whether the date will display with the prefix 19 or 20.

For example if you enter the number 50, the statements will indicate that:

Years entered as 00-49 become 2000-2049.

Years entered as 50-99 become 1950-1999.

Example

In the following example the variable Date1 = 19890120, Date2 = 20101203 and MyYear = 1990.

DIM Date1, Date2 as Date
DIM MyYear As Integer
	Set Format Date "US"
	Set Date Window 75
		Date1 = StringToDate("1/20/89")
		Date2 = StringToDate("12/3/10")
		MyYear = Year("12/30/90")

See Also:

DateWindow() function