EOMONTH Function in SQL

EOMONTH returns the last day of the month that is the indicated number of months before or after start_date.

Syntax

SELECT EOMONTH(start_date, months)

The EOMONTH function syntax has the following arguments:

1. Start_date: Required argument. A date that represents the starting date.

2. Months: Optional argument. The number of months before or after start_date. A positive value for months returns a future date; a negative value returns a past date.

Please note that if months is not an integer, it is truncated.

Examples
select EOMONTH(‘2015-10-27’)
– returns ‘2015-10-31’
select EOMONTH(‘2015-10-27’,1)
– returns ‘2015-11-30’
select EOMONTH(‘2015-10-27’,1.5)
– returns ‘2015-11-30’
select EOMONTH(‘2015-10-27’,10)
– returns ‘2016-08-31’
select EOMONTH(‘2015-10-27’,-10)
– returns ‘2014-12-31’

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s