Skip to content

Instantly share code, notes, and snippets.

@ImkeF
Created November 19, 2019 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ImkeF/aa8b9f066be1defb9275773c680cc59d to your computer and use it in GitHub Desktop.
Save ImkeF/aa8b9f066be1defb9275773c680cc59d to your computer and use it in GitHub Desktop.
Transforms and converts a <code>date</code> field to YYYYMMDD - text field.
let func =
(DateToTransform as date) as text =>
Text.From(Date.Year(DateToTransform))
& Text.PadStart(Text.From(Date.Month(DateToTransform)),2,"0")
& Text.PadStart(Text.From(Date.Day(DateToTransform)),2,"0") ,
documentation = [
Documentation.Name = " Date.ToDateKey ",
Documentation.Description = " Transforms and converts a <code>date</code> field to YYYYMMDD - text field. ",
Documentation.LongDescription = " Transforms and converts a <code>date</code> field to YYYYMMDD - text field. ",
Documentation.Category = " Date ",
Documentation.Source = " www.TheBIccountant.com . ",
Documentation.Version = " 1.0 ",
Documentation.Author = " Imke Feldmann: www.TheBIccountant.com. ",
Documentation.Examples = {[Description = " ",
Code = " Date.ToDateKey(#date(2019,1,1) ",
Result = " ""20190101"" "]}]
in
Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment