Forum Discussion
Get Date As Text
- Anonymous4 years ago
Try this:
Date.ToText(Date.From([mydate]),[Format = "YYYYMMDD"])
--Nate
Thanks Nate,
That is giving me an error:
Expression.Error:We cannot convert the value 0 to type Text.
Details:
Value = 0
Type = [Type]
Where mytime = 2/22/2022 9:10:31 AM
Thanks,
-w
- Anonymous4 years agoNot applicable
My bad!
Text.Select(Date.ToText(Date.From([mydate]),[Format = "YYYYMMDD"]), {"0".."9"})
--Nate
- UncleLewis4 years agoResponsive Resident
Thanks Nate,
That works for YYYYMMDD, I'm trying to get to YYYYMMDD_HHMMSSI change the format string to YYYYMMDD_HHMMSS
But that is returning a format error
Could a solution be to split the date, time into 2 different fields, convert each field to text, then concatenate each field to the id so the final PK is in the format id_YYYYMMDD_HHMMSS?Thanks,
-w
- Anonymous4 years agoNot applicable
If it's a datetime field, just use DateTime.ToText, and remove the Date.From.
--Nate