Changing the time in your column to an am/pm format is straightforward, just follow the steps below or check out the video walkthrough.
- Extract the hour from your column that has the time in in by using the column dropdown, selecting extract, and then selecting hour.
- Next, add a new column, and use this formula:
if(extract_hour > 12) then "pm" else "am"
This will segment each row into either am or pm - Now change the formatting of the datetime column to year-month-day time using the column dropdown or by using this formula:
your_column_name.format("YYYY-MM-DD HH24:MI") - Extract the time from this column using this formula:
your_column_name.extract(" (.*)")
Which will pull the time section from the column, as it extracts all info after a space. - Now we have a column with the times, e.g. 19:25, 7:46, etc. and another column with either am or pm. All we need to do is combine these columns by adding a new column and using '+' to combine them:
your_time_column_name + your_ampm_column_name - Now you should have a column with 19:25pm, 7:46am and so on.
Note: always remember to change the 'your_column_name' parts of the formulas to the actual column name that you're using.
Comments
0 comments
Please sign in to leave a comment.