Date
Class Date

Method PrototypeDescription
Function AbbreviatedDate() As Stringreturns a date with an abbreviated month

Sub Constructor()initializes to the current date/time

Function Day() As Integerget the current day of the month
Sub Day(Assigns i As Integer)set the current day of the month

Function DayOfWeek() As Integerget the day of the week, from 1 (Sunday) to 7 (Saturday)

Function DayOfYear() As Integerget the number of days into the year (1 = January 1st)

Function GMTOffset() As Doubleget the time zone, as hours offset from GMT time
Sub GMTOffset(Assigns o As Double)set the time zone, as hours offset from GMT time

Function Hour() As Integerget the hour, from 0 (midnight) to 23 (11:00 P.M.)
Sub Hour(Assigns h As Integer)set the hour, from 0 (midnight) to 23 (11:00 P.M.)

Function LongDate() As Stringget a fully spelled-out date string

Function LongTime() As Stringget a fully spelled-out time string

Function Minute() As Integerget the minutes past the hour, from 0 to 59
Sub Minute(Assigns m As Integer)set the minutes past the hour, from 0 to 59

Function Month() As Integerget the month number, from 1 (January) to 12 (December)
Sub Month(Assigns m As Integer)set the month number, from 1 (January) to 12 (December)

Function Operator_Compare( other As Date ) as Integercompare to another Date

Function Second() As Integerget the seconds past the minute, from 0 to 59
Sub Second(Assigns s As Integer)set the seconds past the minute, from 0 to 59

Function ShortDate() As Stringget a shorter date string

Function ShortTime() As Stringget a shorter time string

Function SQLDate() As Stringget the date in SQL form, YYYY-MM-DD
Sub SQLDate(Assigns s As String)set the date in SQL form, YYYY-MM-DD

Function SQLDateTime() As Stringget the date/time in SQL form, YYYY-MM-DD HH:MM:SS
Sub SQLDateTime(Assigns s As String)set the date/time in SQL form, YYYY-MM-DD HH:MM:SS

Function TotalSeconds() As Doubleget the seconds since 12:00 AM on January 1, 1904
Sub TotalSeconds(Assigns s As Double)set the seconds since 12:00 AM on January 1, 1904

Function WeekOfYear() As Integerget the number of weeks into the year (first week is 1)

Function Year() As Integerget the year
Sub Year(Assigns y As Integer)set the year


The Date class represents a date and time in Yuma. Whenever you create a new Date object, it is initialized to the current date and time. You can make it represent some other date/time in several ways. First, you could assign invidivdually to the Year, Month, Day, Hour, Minute, and Second properties (and it's best to assign them in that order). Or you could assign to just the SQLDateTime (or SQLDate) properties. Finally, you can also assign to the TotalSeconds property; this is a handy way to copy a date/time from one Date object to another.

The Date class includes a comparison operator, so you can safely compare two Date objects, and they will be equated or ordered according to their TotalSeconds values.

The Date class is fairly smart about dealing with invalid dates, converting them to the most sensible equivalent valid date. So, for example, it is safe to compute a date 10 days in the future simply by doing "d.Day = d.Day + 10"; this will automatically roll the date over to the next month or year as needed.

If you need to store a complete date/time in a file, cookie, etc., there are two standard ways of doing so. The easiest is to read and write the SQLDateTime, which provides a full human-readable date string in a standard format. The other is to use the TotalSeconds value (which you could convert to a string using Str or Format, and convert back using Val or CDbl).