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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
wnicholl
Resolver II
Resolver II

Date Field and Calculated Column

Hello,

 

I'm currently using a calculated column to convert this date 20060523 (text field) to 05/23/2006.

 

My calculated column is Effective Date = DATE(LEFT('APPDATP (NB)'[QEFDT],4),MID('APPDATP (NB)'[QEFDT],5,2),LEFT('APPDATP (NB)'[QEFDT],2))

 

Using the above calculated column I'm getting this result 5/20/2006 which is showing the wrong day.  Is there a way to show the corrcet day 5/23/2006?  Thank you in advance!

 

Here is a sample of the date field. The data type = Text and the Format = Text. 

QEFDT
20060523
20070417
20051201
20231021
1 ACCEPTED SOLUTION
wnicholl
Resolver II
Resolver II

I was able to resolve the problem using the folloing steps.

1) Open power query
2) Create a custom query
3) Add the following M Code = Text.BeforeDelimiter([Date Field], " ")
4) Change type to Date/Calender and Rename Field
5) Close and Save

View solution in original post

9 REPLIES 9
wnicholl
Resolver II
Resolver II

I was able to resolve the problem using the folloing steps.

1) Open power query
2) Create a custom query
3) Add the following M Code = Text.BeforeDelimiter([Date Field], " ")
4) Change type to Date/Calender and Rename Field
5) Close and Save

wnicholl
Resolver II
Resolver II

I have the exact formula you provided. Not sure why it's not working for me. Thank you for your help.

 

Effective Date =
               DATE(LEFT('APPDATP (NB)'[QEFDT],4),MID('APPDATP (NB)'[QEFDT],5,2),RIGHT('APPDATP (NB)'[QEFDT],2))

Hi,

The formula is correct.  In the Query Editor, change the data type to Whole Number.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks for reaching out. I changed the data type to Whole Number in query editor and I'm still getting an error. 

I cannot help you unless i see the file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

I'm connected to AS400 so their is no external fime available. I can provide a copy of the data is that helps.  Thank you! 

gadielsolis
Resolver III
Resolver III

Please check if there's a typo, I just tried in my PC and it's working.

gadielsolis_1-1705007476239.png

 

gadielsolis
Resolver III
Resolver III

Hello,

 

You should use Right to get the day, you're currently using left which will get you the first 2 numbers of the year, the correct formula should be:
Effective Date = DATE(LEFT('APPDATP (NB)'[QEFDT],4),MID('APPDATP (NB)'[QEFDT],5,2),RIGHT('APPDATP (NB)'[QEFDT],2))

Effective Date = DATE(LEFT('APPDATP (NB)'[QEFDT],4),MID('APPDATP (NB)'[QEFDT],5,2),RIGHT('APPDATP (NB)'[QEFDT],2))
 
This gives an error "An argumnet of function 'DATE' has the wrong data type or the result is too large or too small.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.