Forum Discussion
How to convert text (data type) to a date (data type)?
Hello guys,
I need your help with converting a text column towards a data type.
Should i add a column with a certain formula to achieve this?
See below the error that I'm getting from this:
Many thanks!!!
Cheers,
DSabsi
Sure (I included some Dutch as well :-) ):
let Source = #table(type table[Verwachte_Start = text],{{"1499032800"},{"1498860000"},{"1493589600"},{"1491170400"}}), AddedUTCDateTime = Table.AddColumn(Source, "Verwachte_startdatum/tijd_UTC", each #datetimezone(1970,1,1,0,0,0,0,0) + #duration(0,0,0,Number.From([Verwachte_Start])), type datetimezone), AddedLocalDate = Table.AddColumn(AddedUTCDateTime, "Verwachte_startdatum_lokaal", each Date.From([#"Verwachte_startdatum/tijd_UTC"]), type date) in AddedLocalDate
14 Replies
- blopez11Super User
Can you give us a sample of what your text data looks like and what data type you are trying to convert it to? That would help in providing an answer
- dsabsiAdvocate I
Hello guys,
My apologies for my late response.
Hereby the sample of the data that I got from my boss:
The format is text and I wish to change it to dates.
I hope you can help me, I'm really astonished by the amount of replies (many thanks!!!!)
Cheers,
DSabsi
- MarcelBeugCommunity Champion
- SivaManiResident Rockstar
MarcelBeug In my experience, Power BI's default date format is MM/DD/YYYY - Because of Locale(by default) in English(United State).
GB's date format is DD/MM/YYYY.
According to your sample date formats,
4th (2017-04-01) and 6th(4/1/2017) formats will be detected as a date by Power BI.
The Rest of them, we have to convert it to the required format. Since it is in English(GB) format. So I have used "en-GB"
I hope I've made it clear enough.
If you have anything apart from this, just tell me it will be helpful.
Thanks,
Siva
- AnonymousNot applicable
- dsabsiAdvocate I
Hi Guys AnonymousSivaManiMarcelBeugblopez11,
I found out that the text value is an epoch value in a text value.
Do you know how to convert an epoch value in a text format to dates value in date format?
Cheers,
DSabsi
- MarcelBeugCommunity Champion
Sure (I included some Dutch as well :-) ):
let Source = #table(type table[Verwachte_Start = text],{{"1499032800"},{"1498860000"},{"1493589600"},{"1491170400"}}), AddedUTCDateTime = Table.AddColumn(Source, "Verwachte_startdatum/tijd_UTC", each #datetimezone(1970,1,1,0,0,0,0,0) + #duration(0,0,0,Number.From([Verwachte_Start])), type datetimezone), AddedLocalDate = Table.AddColumn(AddedUTCDateTime, "Verwachte_startdatum_lokaal", each Date.From([#"Verwachte_startdatum/tijd_UTC"]), type date) in AddedLocalDate
- Nari1998Helper II
Hi All,
I'm stuck at creating a custom date column.
So the thing is i have a date column which is in text datatype as following 09-01-24 (which should be date as in 9 January 2024) and when converting into date it gives error on some dates.How can i fix this in pq?