Forum Discussion
Convert a columns of datatype datetimezone to datetime
Hi h4tt3n ,
You can acheive this by splitting the column.Below i have attached the screenshots for your understanding.
This is your orignal column with Datetimezone
Split Column
Split column:
Select or enter delimeter : Custom
Use +
Split at: Left-most delimeter
Click on OK
Result :
Result,which is a datetime datatype.
If your problem is solved please accept this as solution.
Thank you
orry, this simply discards timezone info, it doesn't incorporate it into the time. However, I have found the solution with a python script.
- artemus6 years ago
Microsoft Employee
In effect you are asking to convert a datetimezone value to a datetime in UTC:
let dtz = ..., udtz = DateTimeZone.SwitchZone(dtz, 0), dt = DateTimeZone.RemoveZone(udtz) in dt - Macc-PA5 years ago
Helper I
Hi, Can you share the steps you used to add the timestamp to the date using python
- h4tt3n5 years ago
Helper V
Macc-PA I think this is the script. After all, it's one year ago, and we ended up not using it anyway.
import pytzimport datetimetz = pytz.timezone('Europe/Copenhagen')dt = datetime.datetime.utcnow()offset_seconds = tz.utcoffset(dt).secondsoffset_hours = offset_seconds / 3600.0#print ("{:+d}:{:02d}".format(int(offset_hours), int((offset_hours % 1) * 60)))print( offset_hours )- Macc-PA5 years ago
Helper I
Thanks for that - in the end we didnt need to use it.
The problem was solved by ensuring our odata datasource was sending the datetime as UTC, ie not converting it to local time.
Once that happened, converting the column to DataTime applied the UTC offset as expected even for datetimes where daylight saving was involved.