Year - return the year

Return to Introduction  Previous page  Next page

$return = Year(date[,date_format])

Where:

 

$return

The four digit year.

date

The input date.

date_format

can be one of the following:

DMY (date is in DD/MM/YYYY format.)

MDY (date is in MM/DD/YYYY format.)

YMD (date is in YYYY/MM/DD or YYYY-MM-DD format.)

 

date_format may be omitted, in which case the date format is taken from the "Option DateFormat" command. If the "Option DateFormat" command is also omitted, then the date format is assumed to be the system short date format.

date and date_format may be a variables.

The Year command returns the four digit year of the input date.

Examples

$Year = Year($DATE)

'Returns the current year in system short date format

$Year = Year("2015-01-01", YMD)

'Returns 2015

$Year = Year("01/01/2016", mdy)

'Returns 2016

 

Sample Script

' Display the date.

$Today = $DATE

$DayNumber = Day($Today)

$MonNumber = Month($Today)

$Year = Year($Today)

'Remove leading zero

$DayNumber = Trim($DayNumber,"0",left)

$MonNumber = Trim($MonNumber,"0",left)

MsgBox("Today is day "  & $DayNumber _

               & " of month " & $MonNumber _

               & " of year "  & $Year)

exit

 

See Also:

 

DateAdd

Day

Month

MonthName

Weekday

WeekdayName

 


TN3270 Plus is continually being improved. To learn more about the latest enhancements, please review our Version History web page.