Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
NazeefKhan19
Frequent Visitor

Cannot get all dates from a certain date to todays date

I am trying to get dates from an admission date to todays date to go into a custom coumn using the following:

 

{ Number.From([admissionDate])..Number.From(DateTime.Date(DateTime.LocalNow)) } 

 

However the custom column i am adding is coming up with an Error which says :

 

'Expression.Error: The DateTime.Date function expects an input of type DateTime or DateTimeZone.
Details:
[Function]'

 

I thought that DateTime.LocalNow did return the date as of now in a date time format? 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

Are you looking for datediff or Dates.

In M

=each Duration.Days([Date1] - [Date2])

 

In dax date diff a new column

datediff([admission date],today(),day)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

TomMartens
Super User
Super User

Hey @NazeefKhan19 ,

 

you have to use parenthesis in combination with DateTime.LocalNow as it is a function like so:

Number.From(DateTime.Date(DateTime.LocalNow()))

 

Hopefully, this provides what you are looking for.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

3 REPLIES 3
TomMartens
Super User
Super User

Hey @NazeefKhan19 ,

 

you have to use parenthesis in combination with DateTime.LocalNow as it is a function like so:

Number.From(DateTime.Date(DateTime.LocalNow()))

 

Hopefully, this provides what you are looking for.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi @TomMartens 

If i am doing the following to get dates between two dates. How do i replace the 'DischargeDate' with today's date if its null?

{ Number.From([AdmissionDate]) ..Number.From([DischargeDate])  }

amitchandak
Super User
Super User

Are you looking for datediff or Dates.

In M

=each Duration.Days([Date1] - [Date2])

 

In dax date diff a new column

datediff([admission date],today(),day)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.