Date/Time functions

AddDays

Declaration

DateTime AddDays(DateTime dateTime, double days)

Description

Adds the number of days to the given DateTime and returns the result.

Supported Runtime Versions

5.0

Parameters Description
dateTime Instance of DateTime.
days Days to add.

Return Value

Adds a number of days to the given DateTime.

AddHours

Declaration

DateTime AddHours(DateTime dateTime, double hours)

Description

Adds the number of hours to the given DateTime and returns the result.

Supported Runtime Versions

5.0

Parameters Description
dateTime Instance of DateTime.
hours Hours to add.

Return Value

Adds a number of hours to the given DateTime.

AddMinutes

Declaration

DateTime AddMinutes(DateTime dateTime, double minutes)

Description

Adds the number of minutes to the given DateTime and returns the result.

Supported Runtime Versions

5.0

Parameters Description
dateTime Instance of DateTime.
minutes Minutes to add.

Return Value

Adds a number of minutes to the given DateTime.

AddMonths

Declaration

DateTime AddMonths(DateTime dateTime, int months)

Description

Adds the number of months to the given DateTime and returns the result.

Supported Runtime Versions

5.0

Parameters Description
dateTime Instance of DateTime.
months Months to add.

Return Value

Adds a number of months to the given DateTime.

AddSeconds

Declaration

DateTime AddSeconds(DateTime dateTime, double seconds)

Description

Adds the number of seconds to the given DateTime and returns the result.

Supported Runtime Versions

5.0

Parameters Description
dateTime Instance of DateTime.
seconds Seconds to add.

Return Value

Adds a number of seconds to the given DateTime.

AddYears

Declaration

DateTime AddYears(DateTime dateTime, int years)

Description

Adds the number of years to the given DateTime and returns the result.

Supported Runtime Versions

5.0

Parameters Description
dateTime Instance of DateTime.
years Years to add.

Return Value

Adds a number of years to the given DateTime.

ConvertToDateTime

Declaration

DateTime ConvertToDateTime(string timestamp)

Description

Converts a culture-invariant string into a DateTime object.

Supported Runtime Versions

5.0

Parameters Description
timestamp String to be converted.

Return Value

A DateTime representation of the string.

ConvertToDateTime

Declaration

DateTime ConvertToDateTime(string timestamp, string cultureName)

Description

Converts a string into a DateTime object.

Supported Runtime Versions

3.0, 4.0, 5.0

Parameters Description
timestamp String to be converted.
cultureName Culture-specific formatting information. For example, "en-US", "ru-RU", or "ja-JP". The value "" means culture-invariant.

Return Value

A DateTime representation of the string.

CreateDateTime

Declaration

DateTime CreateDateTime()

Description

Creates a new date-time object representing the current time and date.

Supported Runtime Versions

1.0, 2.0, 3.0, 4.0, 5.0

Parameters

The function has no parameters.

Return Value

Current time and date as date-time object.

CreateDateTime

Declaration

DateTime CreateDateTime(int year, int month, int day, int hour, int minute, int second)

Description

Creates a new date-time object representing the current time and date.

Supported Runtime Versions

3.0, 4.0, 5.0

Parameters Description
year The year of the date.
month The month of the date.
day The day of the date.
hour The hour of the date.
minute The minute of the date.
second The second of the date.

Return Value

A date-time object representing the specified values.

DayOfWeek

Declaration

int DayOfWeek(DateTime dateTime)

Description

Receives the day of the week represented by a DateTime object.

Supported Runtime Versions

3.0, 4.0, 5.0

Parameters Description
dateTime The DateTime object to receive the day of the week from.

Return Value

The day of the week represented by the DateTime object. 0=Sunday, ..., 6=Saturday.

DaysInMonth

Declaration

int DaysInMonth(int year, int month)

Description

Returns the number of days in the specified month and year.

Supported Runtime Versions

3.0, 4.0, 5.0

Parameters Description
year The year.
month The month (a number ranging from 1 to 12).

Return Value

The number of days in month for the specified year.

GetDateAsString

Declaration

string GetDateAsString(DateTime dateTime)

Description

Returns the date part of a date-time object as a string.

Supported Runtime Versions

1.0, 2.0, 3.0, 4.0, 5.0

Parameters Description
dateTime The date-time object to return the date part for.

Return Value

Date part of the date-time object.

GetDateAsString

Declaration

string GetDateAsString(DateTime dateTime, string culture)

Description

Returns the date part of a date-time object as a string formatted with the standard short date format (en-us: month/day/year).

Supported Runtime Versions

3.0, 4.0, 5.0

Parameters Description
dateTime The date-time object to return the date part for.
culture The language culture name (e.g. "en" or "en-US") of the culture to convert to as specified by Microsoft. You can use country-specific cultures.

Return Value

Date part of the date-time object.

GetDateTimeAsSortableString

Declaration

string GetDateTimeAsSortableString(DateTime dateTime)

Description

Returns the DateTime object as a sortable, culture-independent string of format YYYY/MM/DD-HH:MM:SS. This can be used generally to sort and compare DateTime objects.

Supported Runtime Versions

3.0, 4.0, 5.0

Parameters Description
dateTime The date-time object to convert.

Return Value

Time part of the date-time object.

GetDateTimeAsString

Declaration

string GetDateTimeAsString(DateTime dateTime, string format)

Description

Returns the date-time object as a string converted with the specified format. See Microsoft .Net date and time format strings. You can use all standard and custom format strings.

Supported Runtime Versions

3.0, 4.0, 5.0

Parameters Description
dateTime The date-time object to convert.
format The date-time format string to convert with.

Return Value

Time part of the date-time object.

GetDateTimeAsString

Declaration

string GetDateTimeAsString(DateTime dateTime, string format, string culture)

Description

Returns the date-time object as a string converted with the specified format and culture. See Microsoft .Net date and time format strings. You can use all standard and custom format strings.

Supported Runtime Versions

3.0, 4.0, 5.0

Parameters Description
dateTime The date-time object to convert.
format The date-time format string to convert with.
culture The language culture name (e.g. "en" or "en-US") of the culture to convert to as specified by Microsoft. You can use country-specific cultures.

Return Value

Time part of the date-time object.

GetDay

Declaration

int GetDay(DateTime dateTime)

Description

Returns the day of a given DateTime

Supported Runtime Versions

5.0

Parameters Description
dateTime Instance of DateTime.

Return Value

Day as a number

GetDurationAsDouble

Declaration

double GetDurationAsDouble(DateTime start, DateTime end)

Description

Returns the duration (in seconds) between two date-time objects.

Supported Runtime Versions

3.0, 4.0, 5.0

Parameters Description
start Start of the period to get the duration for.
end End of the period to get the duration for.

Return Value

The duration (in seconds) between start and end.

GetDurationAsString

Declaration

string GetDurationAsString(DateTime start, DateTime end)

Description

Returns the duration (in seconds) between two date-time objects as a string.

Supported Runtime Versions

1.0, 2.0, 3.0, 4.0, 5.0

Parameters Description
start Start of the period to get the duration for.
end End of the period to get the duration for.

Return Value

The duration (in seconds) between start and end.

GetDurationInMilliseconds

Declaration

double GetDurationInMilliseconds(DateTime start, DateTime end)

Description

Returns the duration (in milliseconds) between two DateTime objects.

Supported Runtime Versions

5.0

Parameters Description
start Start of the period to receive the duration for.
end End of the period to receive the duration for.

Return Value

The duration (in milliseconds) between start and end.

GetHour

Declaration

int GetHour(DateTime dateTime)

Description

Returns the hour of a given DateTime

Supported Runtime Versions

5.0

Parameters Description
dateTime Instance of DateTime.

Return Value

Hour as a number

GetMinutes

Declaration

int GetMinutes(DateTime dateTime)

Description

Returns the minutes of a given DateTime

Supported Runtime Versions

5.0

Parameters Description
dateTime Instance of DateTime.

Return Value

Minutes as a number

GetMonth

Declaration

int GetMonth(DateTime dateTime)

Description

Returns the month of a given DateTime

Supported Runtime Versions

5.0

Parameters Description
dateTime Instance of DateTime.

Return Value

Month as a number

GetSeconds

Declaration

int GetSeconds(DateTime dateTime)

Description

Returns the seconds of a given DateTime

Supported Runtime Versions

5.0

Parameters Description
dateTime Instance of DateTime.

Return Value

Seconds as a number

GetTimeAsString

Declaration

string GetTimeAsString(DateTime dateTime)

Description

Returns the time part of a date-time object as a string.

Supported Runtime Versions

1.0, 2.0, 3.0, 4.0, 5.0

Parameters Description
dateTime The date-time object to return the time part for.

Return Value

Time part of the date-time object.

GetTimeAsString

Declaration

string GetTimeAsString(DateTime dateTime, string culture)

Description

Returns the time part of a date-time object as a string formatted with the standard short time format (en-us: hour:minute AM/PM). Be aware that country-specific short time format can hold AM/PM or other formats that does not only hold hour, minute, and seconds.

Supported Runtime Versions

3.0, 4.0, 5.0

Parameters Description
dateTime The date-time object to return the time part for.
culture The language culture name (e.g. "en" or "en-US") of the culture to convert to as specified by Microsoft. You can use country-specific cultures.

Return Value

Time part of the date-time object.

GetYear

Declaration

int GetYear(DateTime dateTime)

Description

Returns the year of a given DateTime

Supported Runtime Versions

5.0

Parameters Description
dateTime Instance of DateTime.

Return Value

Year as a number