Date and Time Functions

Articles

dateadd
Adds or subtracts a certain duration of time to an existing date or time value. Function result = dateadd(period, count, input) Arguments Argument Data Type period datepart count integer input date or time or datetime resu...
datediff
Returns the duration of time between two date or time values. Function result = datediff(period, first, second) Arguments Argument Data Type period datepart first date or time or datetime second date or time or datetime re...
datefromparts
Returns a date-only value with given numerical year, month and day values. Function result = datefromparts(year, month, day) Arguments Argument Data Type year integer month integer day integer result date Comments Co...
datename
Returns the text name for part of a date, such as the name of a month or the weekday name. Function result = datename(part, input) Arguments Argument Data Type part datepart input date or time or datetime result string Co...
datetimefromparts
Returns a date-time value with given numerical year, month, day, hour, minute, second values. Function result = datetimefromparts(year, month, day, hour, minute, second) Arguments Argument Data Type year integer month integer ...
day
Returns the day-of-month part of a date or date-time value. Function result = day(input) Arguments Argument Data Type input date (datetime will be implicitly cast to date) result integer Comments Returns the day of a date as...
dayofyear
Returns the day of the year as a number for a given date or date-time. Function result = dayofyear(input) Arguments Argument Data Type input date (datetime will be implicitly cast to date) result integer Comments Returns the...
getdate
Returns the current date for the current user as a date-only value. Function result = getdate() Arguments Argument Data Type result date Comments The current date in the local time zone. See Dates, Times and Time Zones . Examp...
getdatetime
Returns the current date and time as a date-time value. Function result = getdatetime() Arguments Argument Data Type result datetime Comments The current date time determined in UTC, but presented in local time zone. See Dates...
gettime
Returns the current time for the current user as a time-only value. Function result = gettime() Arguments Argument Data Type result time Comments The current time in the local time zone. See Dates, Times and Time Zones . Examp...
hour
Returns the hour of a time or date-time value as a number. Function result = hour(input) Arguments Argument Data Type input time (datetime will be implicitly cast to time) result integer Comments Returns the hour of a time a...
minute
Returns the minute of a time or date-time value as a number. Function result = minute(input) Arguments Argument Data Type input time (datetime will be implicitly cast to time) result integer Comments Returns the minute of a ...
month
Returns the month of a date or date-time value as a number. Function result = month(input) Arguments Argument Data Type input date (datetime will be implicitly cast to date) result integer Comments This function operates in ...
quarter
Returns the calendar quarter of a date or date-time value as a number. Function result = quarter(input) Arguments Argument Data Type input date (datetime will be implicitly cast to date) result integer Comments This function...
second
Returns the seconds of a time or date-time value as a number. Function result = second(input) Arguments Argument Data Type input time (datetime will be implicitly cast to time) result integer Comments Returns the second of a...
timefromparts
Returns a time-only value with given numerical hour, minute and seconds values. Function result = timefromparts(hour, minute, second) Arguments Argument Data Type hour integer minute integer second integer result time ...
week
Returns the week of the year as a number. Function result = week(input) Arguments Argument Data Type input date (datetime will be implicitly cast to date) result integer Comments This function operates in the local time-zone...
weekday
Returns the day of the week as a number, where Sunday is the first day of the week and returns 1. Function result = weekday(input) Arguments Argument Data Type input date (datetime will be implicitly cast to date) result integer ...
year
Returns the year of a date or date-time value as a number. Function result = year(input) Arguments Argument Data Type input date (datetime will be implicitly cast to date) result integer Comments This function operates in th...