Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello
I have the following table
Current, i am unable to change the data type of the column to DateTime, as the value with Today or Yesterday are not recognised as date.
How can i replace the word Today with Today Date and yesterday with Yesterday's date.
So i can change the data type to DateTime?
Thanks
Solved! Go to Solution.
Hi @PPStar ,
You can make a little adjustment base on the reply from @mh2587 ,please find details in the attachment.
=if Text.Contains([Start time], "Today") then
DateTime.ToText(DateTime.LocalNow(), "yyyy-MM-dd") & Text.AfterDelimiter([Start time], ",")
else if Text.Contains([Start time], "Yesterday") then
DateTime.ToText(DateTime.From(DateTime.LocalNow() - #duration(1, 0, 0, 0)), "yyyy-MM-dd")
& Text.AfterDelimiter([Start time], ",")
else
[Start time]
Best Regards
= if Text.Contains([YourColumnName], "Today") then DateTime.ToText(DateTime.LocalNow(), "yyyy-MM-dd")
else if Text.Contains([YourColumnName], "Yesterday") then DateTime.ToText(DateTime.From(DateTime.LocalNow() - #duration(1, 0, 0, 0)), "yyyy-MM-dd")
else [YourColumnName]
Did I answer your question? If so, please mark my post as a solution!
Proud to be a Super User!
Hello, this almost works.
The only issue is the time. I thikn using the dd/MM/yyyy HH:MM:ss shows todays date and todays time, but i need it to show the time on the table
E.g if you look at the 2nd row, it says Today, 07:00 . So the new column shows it as 20/11/2023 12:11:11, where 12:11:11 is the Hour, Minute Second NOW.
Any ideas?
Thanks
Hi @PPStar ,
You can make a little adjustment base on the reply from @mh2587 ,please find details in the attachment.
=if Text.Contains([Start time], "Today") then
DateTime.ToText(DateTime.LocalNow(), "yyyy-MM-dd") & Text.AfterDelimiter([Start time], ",")
else if Text.Contains([Start time], "Yesterday") then
DateTime.ToText(DateTime.From(DateTime.LocalNow() - #duration(1, 0, 0, 0)), "yyyy-MM-dd")
& Text.AfterDelimiter([Start time], ",")
else
[Start time]
Best Regards
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
105 | |
79 | |
69 | |
62 |
User | Count |
---|---|
143 | |
104 | |
103 | |
82 | |
70 |