Date and Time Functions
Date and Time Functions
Functions
CALENDAR
CALENDARAUTO
DATE
DATEDIFF
By Mallikarjun Thammaneni
DATEVALUE
DAY
HOUR
MINUTE
MONTH
NOW
QUARTER
SECOND
TODAY
WEEKDAY
WEEKNUM
YEAR
By Mallikarjun Reddy
By Mallikarjun Thammaneni
It returns a table with a single column name “Data” that
contains a continuous set of the dates.
CALENDAR
Syntax: Example:
CALENDAR( CALENDAR(DATE(2012,01,01),DATE(2022,12,31)
<start_date>, <end_date>)
CALENDAR(DATE(2012,01,01),TODAY())
By Mallikarjun Reddy
By Mallikarjun Thammaneni
It returns a table with one column of dates calculated from
the model automatically.
CALENDARAUT <FiscalYearEndMonth> any DAX expression that returns
O an integer from 1 to 12.
Syntax: Example:
CALENDARAUTO( CALENDARAUTO() return all dates from Jan-10-2020 to
[Fiscal Year End Month]) Dec -31-2022
By Mallikarjun Reddy
By Mallikarjun Thammaneni
It returns the specified date and time
DATE
Syntax: Example:
DATE( DATE(2021,01,01)
<year>,<month>,<day>)
Out Put:-
01/01/2022 12:00:00 AM
By Mallikarjun Reddy
By Mallikarjun Thammaneni
It return the datetime format between two dates, as you
specified in two dates.
DATEDIFF
Date1- It means Start datetime
Date2- End Datetime
Syntax: Interval – SECOND, MINUTE, HOUR,DAY, WEEK,
DATEDIFF( <Date1>,<Date2>,<Int MONTH, QUARTER,YEAR
erval>)
Example:
DATEDIFF(DATE(2021,06,01),DATE(2022,07,31)
By Mallikarjun Reddy
By Mallikarjun Thammaneni
It converts the date in text format to Datetime format.
DATEVALUE
Syntax: Example:
DATEVALUE(date_text ) DATEVALUE(“08/01/2022”)
OUTPUT:-
01/08/2022 12:00:00 AM
By Mallikarjun Reddy
By Mallikarjun Thammaneni
It Returns the day of the month, a number from 1-31.
DAY
Syntax: Example:
DAY(<date>) DAY(CalendarDim[Date])
By Mallikarjun Reddy
By Mallikarjun Thammaneni
It Returns as hours a number from 0 to 23.
HOUR()
Syntax: Example:
HOUR(<datetime>) HOUR(CalendarDim[Date])
By Mallikarjun Reddy
By Mallikarjun Thammaneni
It Returns as minute a number from 0 to 59.
MINUTE()
Syntax: Example:
MINUTE(<datetime>) MINUTE(CalendarDim[Date])
By Mallikarjun Reddy
By Mallikarjun Thammaneni
It Returns the month as a number from 1(January) to
12(December).
MONTH()
Syntax: Example:
MONTH(<datetime>) MONTH(CalendarDim[Date])
By Mallikarjun Reddy
By Mallikarjun Thammaneni
It returns the current date and time in datetime format
NOW()
Syntax: Example:
NOW( )
NOW()
By Mallikarjun Reddy
By Mallikarjun Thammaneni
It returns the quarter number as Integer number
From 1 to 4
QUARTER()
Q1 (Jan to Mar) Q2(Apr to Jun)
Q3(July to Sep) Q4(Oct to Dec)
Syntax:
QUARTER(<date> ) Example:
QUARTER(Calendar[Date])
By Mallikarjun Reddy
By Mallikarjun Thammaneni
It Returns the seconds of time value, and returns number
from 0 to 59.
SECOND()
Syntax: Example:
SECOND(<time>) SECOND(CalendarDim[Date])
By Mallikarjun Reddy
By Mallikarjun Thammaneni
It return the current date.
TODAY
Syntax: Example:
TODAY( ) TODAY()
OUTPUT:-
10/07/2022 12:00:00 AM
By Mallikarjun Reddy
By Mallikarjun Thammaneni
It Returns weekday as integer number from
1(Sunday) to 7(Saturday).
WEEKDAY()
Syntax: Example:
WEEKDAY( WEEKDAY(CalendarDim[Date])
<date>,<return_type>)
By Mallikarjun Reddy
By Mallikarjun Thammaneni
It Returns week number as integer number from 1 to 52.
WEEKNUM()
Syntax: Example:
WEEKNUM( WEEKNUM(CalendarDim[Date])
<date>[,<return_type>])
By Mallikarjun Reddy
By Mallikarjun Thammaneni
It Returns the year of date as a four digits integer number
Like 2020- 2022
YEAR()
Syntax: Example:
YEAR(<date>) YEAR(CalendarDim[Date])
By Mallikarjun Reddy
THANK YOU
By Mallikarjun Thammaneni