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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Date exctracting from specific timestamp

Hi community, 

 

Would you please give me advice what is the best way to extract the date from this specific timespamp:

 

P2019Y3M11DT11H4M54S

 

I've tried to use MID function to exctract the parts and concatenate them by ".": 

 

Date =

MID ( Test_table[orderDate] ; SEARCH ( "M" ; Test_table[orderDate] ) + 1 ; SEARCH ( "D" ; Test_table[orderDate] ) - SEARCH ( "M" ; Test_table[orderDate] ) - 1 ) & "." &
MID ( Test_table[orderDate] ; SEARCH ( "Y" ; Test_table[orderDate] ) + 1 ; SEARCH ( "M" ; Test_table[orderDate] ) - SEARCH ( "Y" ; Test_table[orderDate] ) - 1 ) & "." &
MID ( Test_table[orderDate] ; SEARCH ( "P" ; Test_table[orderDate] ) + 1 ; 4 )
 
As result I received a text string "11.3.2019", but not able to change the format to Date.
 
Would be really appreciate for your help.
 
Thank you!
1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

I would do something like this:

DATE(
    VALUE(< something that returns the year >)
    ,VALUE(< something that returns the month >)
    ,VALUE(< something that returns the day >)
)

Regards,
Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thank you guys, now it works!

TomMartens
Super User
Super User

Hey,

 

I would do something like this:

DATE(
    VALUE(< something that returns the year >)
    ,VALUE(< something that returns the month >)
    ,VALUE(< something that returns the day >)
)

Regards,
Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
AliH
Frequent Visitor

Hi Egor,

 

test:=date(mid("P2019Y3M11DT11H4M54S",find("P","P2019Y3M11DT11H4M54S")+1,4),mid("P2019Y3M11DT11H4M54S",find("M","P2019Y3M11DT11H4M54S")+1,2),mid("P2019Y3M11DT11H4M54S",find("Y","P2019Y3M11DT11H4M54S")+1,1))

 

Probably not the best way, but this works.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors