Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

3.5 Date & Time Functions

Lesson 26 of 62 in the free Power BI notes on Siksha Sarovar, written by Rohit Jangra.

DAX Date & Time Functions

Date and time functions are crucial for time-based analysis — one of the most common requirements in business intelligence.

Basic Date Functions

TODAY() and NOW()

FunctionReturnsExample
TODAY()Current date (no time)2025-02-17
NOW()Current date and time2025-02-17 10:30:45

Example — Days Since Order:

Days Since Order = TODAY() - Sales[OrderDate]

YEAR(), MONTH(), DAY()

Extract specific parts from a date.

FunctionExtractsExample (for 2025-02-17)
YEAR()Year2025
MONTH()Month number2
DAY()Day of month17
WEEKDAY()Day of week (1=Sun)2 (Monday)
WEEKNUM()Week number of year8
HOUR()Hour from time10
MINUTE()Minute from time30

Example:

Order Year = YEAR(Sales[OrderDate])
Order Month = MONTH(Sales[OrderDate])

DATE()

Creates a date from year, month, and day values.

Syntax: DATE(Year, Month, Day)

Example:

Start Date = DATE(2025, 1, 1)

DATEADD()

Returns a table of dates shifted by a specified interval.

Syntax: DATEADD(Dates, NumberOfIntervals, Interval)

Intervals: DAY, MONTH, QUARTER, YEAR

Examples:

Last Year Sales = CALCULATE([Total Sales], DATEADD(Dates[Date], -1, YEAR))
Last Month Sales = CALCULATE([Total Sales], DATEADD(Dates[Date], -1, MONTH))

DATEDIFF()

Returns the difference between two dates in a specified unit.

Syntax: DATEDIFF(StartDate, EndDate, Interval)

Intervals: DAY, MONTH, QUARTER, YEAR, HOUR, MINUTE, SECOND

Examples:

Order Age (Days) = DATEDIFF(Sales[OrderDate], TODAY(), DAY)
Customer Tenure (Months) = DATEDIFF(Customers[JoinDate], TODAY(), MONTH)

EOMONTH()

Returns the last day of the month, N months from the given date.

Syntax: EOMONTH(StartDate, Months)

Example:

End of Current Month = EOMONTH(TODAY(), 0)
End of Next Month = EOMONTH(TODAY(), 1)
End of Previous Month = EOMONTH(TODAY(), -1)

CALENDAR() and CALENDARAUTO()

Generate a date table.

CALENDAR():

DateTable = CALENDAR(DATE(2020, 1, 1), DATE(2025, 12, 31))

CALENDARAUTO():

DateTable = CALENDARAUTO()

Automatically detects date range from your data.

Quick Reference

FunctionPurposeExample
TODAY()Current dateTODAY()
NOW()Current date/timeNOW()
YEAR()Extract yearYEAR([Date])
MONTH()Extract monthMONTH([Date])
DATE()Create a dateDATE(2025,1,1)
DATEADD()Shift datesDATEADD(Dates[Date],-1,YEAR)
DATEDIFF()Difference between datesDATEDIFF([Start],[End],DAY)
EOMONTH()End of monthEOMONTH(TODAY(),0)
CALENDAR()Generate date tableCALENDAR(start, end)