Month() function - 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

Returns the month component (1 - 12) of a date value. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

Month( date_expr ) 

date_expr is a date expression.

Return Value

SmallInt value from 1 to 12, inclusive.

Description

The Month() function returns an integer, representing the month component (one to twelve) of the specified date.

Examples

The following example shows how you can extract just the month component from a particular date value, using the Month() function.

If Month(CurDate()) = 12 Then
	'
	' ... then it is December...
	'
End If

You can also use the Month() function within the SQL Select statement. The following Select statement extracts only particular rows from the Orders table. This example assumes that the Orders table has a Date column, called Order_Date. The Select statement's Where clause tells MapInfo Pro to only select the orders from December of 2013.

Open Table "orders"
Select * 
	From orders 
	Where Month(orderdate) = 12 And Year(orderdate) = 2013

See Also:

CurDate() function, Day() function, Minute() function, Month() function, Second() function, Weekday() function, Year() function