Forum Discussion
dsabsi
9 years agoAdvocate I
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 thi...
- 9 years ago
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
MarcelBeug
9 years agoCommunity 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
AddedLocalDatedsabsi
9 years agoAdvocate I
Hi MarcelBeug,
Thank you for your solution, you're great!
I also learned that an alternative to this is:
1. Convert the text to a number by the following formula (creat new column) : Verwachte start number = value([verwachte_start] )/(60*60*24)
2. Convert the value to a year date format (create new column) : Verwachte StartJaar = YEAR(IF([Verwachte start number] = BLANK() ;BLANK();DATEVALUE("01/01/1970") + [Verwachte start number]))
Cheers,
DSabsi