Forum Discussion
AnandNamburi
Helper III
5 years agoHow limit the below code to display till current date only.
Hi All,
I'm using the below code to get the Time Dim.
But my the dates are getting more than what we are(>current date/today).
can any one suggest how we can fine tune the below code so that it shoud not exceed the current year(It shoud be dynamic).
Logic:
let
StartDate = #date(2017,04,01),
YearsToGenerate=20,
BaseList=List.Dates( StartDate,
YearsToGenerate*366,
#duration(1,0,0,0)
),
#"Converted to Table" = Table.FromList(BaseList, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
#"Converted to Table"
Thanks,
Anand
AnandNamburi Try this code
let StartDate = #date(2017,04,01), Today = Date.From(DateTime.LocalNow()), GetDateCount = Duration.Days(Today - StartDate) + 1, BaseList=List.Dates( StartDate, GetDateCount, #duration(1,0,0,0) ), #"Converted to Table" = Table.FromList(BaseList, Splitter.SplitByNothing(), null, null, ExtraValues.Error) in #"Converted to Table"
2 Replies
- amitchandak
Super User
AnandNamburi , I think you can use this in place of days you are giving in List.Dates
Duration.Days(DateTime.LocalNow() - [StartDate])
- parry2k
Super User
AnandNamburi Try this code
let StartDate = #date(2017,04,01), Today = Date.From(DateTime.LocalNow()), GetDateCount = Duration.Days(Today - StartDate) + 1, BaseList=List.Dates( StartDate, GetDateCount, #duration(1,0,0,0) ), #"Converted to Table" = Table.FromList(BaseList, Splitter.SplitByNothing(), null, null, ExtraValues.Error) in #"Converted to Table"