Forum Discussion
Anonymous
4 years agoNot applicable
in PowerQueryEditor, Convert DateTime to YYYMM
I am reading a table from SQL Server and I need to convert a datetime column to YYYYMM. or YYYY-MM. Intellisense is not helping much. My last failed attempt was this: = Table.AddColumn(dbo_OLAP...
- Anonymous4 years ago
Unfortunately, this leaves you with a text field. If you want it to be useable as a date:
From the Power Query Editor, add a new column as beginning of month:
Table.AddColumn(#"Filtered Rows", "dtStartOfMonth", each Date.StartOfMonth([dtRunDate]), type datetime)
From the Data View, format the date using yyyy-mm:
dtRunMonth = FORMAT(OLAPJobHistory[dtStartOfMonth],"yyyy-mm")
Anonymous
4 years agoNot applicable
This worked for me:
= Table.AddColumn(dbo_OLAPJobHistory, "dtRunMonth", each DateTime.ToText([dtRunDate],"yyyyMM"))
Thank you
bcdobbs
4 years agoCommunity Champion
Missed that you said datetime in question. Glad it's working.