Day - returns a number representing the day of the month

Return to Introduction  Previous page  Next page

$return = Day(date[,date_format])

Where:

 

$return

A number from 1 to 31 representing the day of the month.

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 Day command returns a number between 1 and 31 for the day of the month of the input date.

Examples

$DayOfMonth = Day($DATE)

"Returns today's day of the month using system short date format.

$DayOfMonth = Day("2015-01-01", YMD)

'Returns 01

$DayOfMonth = Day("2015-01-02", ymd)

'Returns 02

 

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

Year


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