Hey, you can easily achieve this transformation using SAS or Python, depending on your preference.
In SAS:
You can use the INPUT function to read the original datetime format and then split it into date and time columns:
sas
data B; set A; format Date mmddyy10. Time timeampm.; datetime = input(OriginalColumn, datetime20.); Date = datepart(datetime); Time = timepart(datetime); run;
In Python (Pandas):
Using Python, you can achieve the same with datetime and strftime:
python
import pandas as pd data = {'OriginalColumn': ['11JAN21:13:15:00', '12JUL02:12:30:02']} df = pd.DataFrame(data) # Convert to datetime df['Datetime'] = pd.to_datetime(df['OriginalColumn'], format='%d%b%y:%H:%M:%S') # Extract Date and Time df['Date'] = df['Datetime'].dt.strftime('%m/%d/%Y') df['Time'] = df['Datetime'].dt.strftime('%I:%M:%S%p') print(df[['Date', 'Time']])
Handling date and time can sometimes cause issues with formats like leap years or AM/PM shifts. That could be tricky, especially with February's 28-29 day inconsistency. It was fixed with an additional C++ class in Timechart Work Time.