Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
WMUBeene
Frequent Visitor

date from yyyymmdd stored as whole number

I have a large chunk of data that I have downloaded from our ERP system and am trying to work with.  The only hitch in this process is the that my date columns (AUDTDATE as the example below) are stored as yyyymmdd and PBI sees them as Decimal Numbers.  

 

The simple step of just changing the Data Type doesn't work (i tried).

 

Does anyone have any suggestions to convert these to usable dates?

 

 

Capture.PNG

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

I'm not really sure why it's not working for you but you could try to create a new column with the following M-code:

=Date.FromText(Text.From([insert-your-column-name-here]))

 

I hope this helps,

Magnus

 

View solution in original post

 

Thank you Magnus, I will try this later for my education and let you know if it works for me later.  However, I found a really simple workaround, once I quite looking at the problem so hard, and want to share here for others.  It was a "I can't believe I didn't think of that sooner" moment.

 

The actual column containing the dates I needed is called DTCOMPLETE, below.

Capture.PNG

In the Query, I split this column into three columns call ReceiptYR, ReceiptMo, and RecieptDay.

Capture2.PNG

 

In the table view, I created a calculated column using the Date function to bring all of this back together and format as needed.

 

ReceiptDate = DATE(PORCPL[ReceiptYR],PORCPL[ReceiptMo],PORCPL[ReceiptDay])

Capture3.PNG

View solution in original post

14 REPLIES 14
haniewais
Microsoft Employee
Microsoft Employee

I just wanted to add that the only way I got my date as int (yyymmdd) converted to text is using the Value.FromText first:

     

       Date.FromText(Text.From(Value.FromText([myDateAsInt]))))

 

Full line forrefrence:

      #"mySecondTable" = Table.AddColumn(

                   #myFirstTable, "DateAsDate", each Date.FromText(Text.From(Value.FromText([myDateAsInt])))

      )

Anonymous
Not applicable

I guess that could depend on the culture (Locale) settings you have for Power BI. On my machine for example I have Swedish and it works fine for me to change the data type to dates in the query editor when the values are stored in format yyyymmdd.

 

Otherwise you can create a new column in the query editor using the M-function #Date and extract year, month and day from the original date column to get a proper datevalue.

 

Br,

Magnus

Thanks for the feedback.  I went into options/ reginal settings and switched my locale to Swedan.  This did not change the result.  It still Errors out when trying to convert.  Did you mean that I would need to adjust locale elsewhere?

 

Can you expand on how to use #date to make this happen.  I'm a newbie to M code and cannot seem to find any good information on how to apply this.

 

Capture.PNG

Anonymous
Not applicable

I'm not really sure why it's not working for you but you could try to create a new column with the following M-code:

=Date.FromText(Text.From([insert-your-column-name-here]))

 

I hope this helps,

Magnus

 

Hi can this be made to display only the date? It is currently showing as 

10-Feb-19 00:00:00

 

Thanks allot

I don't have a great dataset to test this one right now but there should be a "Data Type" option where you can swicth "Date/Time" to just "Date".  

Thanks!Solved my problem!

I'm starting with power bi for first time so i'm confused here Should it be like this Date.FromText(Text.From([BusinessDate])) or Date.FromText(Text.From(["BusinessDate"])) or Date.FromText(Text.From(['BusinessDate'])) Thanks In Advance

Column name should be in quotes ("ColumnNameHere ")

I'm confused here should it be like Date.FromText(Text.From([BusinessDate]) or Date.FromText(Text.From(["BusinessDate"]) thanks in advance


This M-Code works perfectly for me. Thank you

Thank you so much Magnus! It took me 2 hours to find the answer to this problem and your answer saved me!

I fianlly got to try this solution over the weekend and it worked great.  Thank you for your insight.

 

Thank you Magnus, I will try this later for my education and let you know if it works for me later.  However, I found a really simple workaround, once I quite looking at the problem so hard, and want to share here for others.  It was a "I can't believe I didn't think of that sooner" moment.

 

The actual column containing the dates I needed is called DTCOMPLETE, below.

Capture.PNG

In the Query, I split this column into three columns call ReceiptYR, ReceiptMo, and RecieptDay.

Capture2.PNG

 

In the table view, I created a calculated column using the Date function to bring all of this back together and format as needed.

 

ReceiptDate = DATE(PORCPL[ReceiptYR],PORCPL[ReceiptMo],PORCPL[ReceiptDay])

Capture3.PNG

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.