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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors