Derive a new column based on Time stamp

user8545255

I have a column 'customer_date' with datatype text.

Based on the time i need to derive a new column

Condition :

  • when customer_date <12 then 'AM' else 'PM


customer_date

01Mar2018 10:03:54
02Mar2018 13:03:54

expected output

  customer_date             session

01Mar2018 10:03:54        AM
02Mar2018 13:03:54        PM

It throws me error when i wrote

select 
case EXTRACT(HOUR FROM customer_date)<12 then 'AM' else 'PM' end as session
from my table;
Gordon Linoff

This works when I test it:

select (case when EXTRACT(HOUR FROM customer_date::timestamp) < 12 then 'AM' else 'PM' end) as session
from mytable;

I added the explicit conversion and the when.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

mutate new column based on sequence of time stamp in dbplyr

From Dev

mysql update based on time stamp in another column

From Dev

Python- Can't overwrite first column of .csv file with new time stamp

From Dev

failed to save new file with time stamp

From Dev

Add a new column based on the current time

From Dev

Sorting rows of data frame based on time stamp

From Dev

"time_stamp" column too ambiguous

From Dev

Sort Excel table based on date in text with time stamp and time zone

From Dev

how to count a column by month if the date column has time stamp?

From Dev

How to create a new column based on time difference of two columns in Pandas?

From Dev

How to add a new column based on the value in the field `time`

From Dev

Bin java time stamp by hour/half hour based on date

From Dev

SQL Join same table based on time stamp and inventory level

From Dev

Searching the relevent rows and adding rows based on time stamp

From Dev

Increase value of time"stamp" based on previous content - string

From Dev

sql sum a column and also return the last time stamp

From Dev

How to create an index on a Time_Stamp column in MySQL?

From Dev

Derive date column based on current date and fixed start date

From Dev

crosstab query - dynamically derive column headings based on a related table

From Dev

Derive date column based on current date and fixed start date

From Dev

How to derive a column based on multiple columns values for a single row

From Dev

Time stamp in VHDL

From Dev

Undefined Time Stamp format?

From Dev

Time stamp in hMAC authentication

From Dev

Time stamp conversion in php

From Dev

Logical delete with a Time stamp

From Dev

Angularjs - date/time stamp

From Dev

Manipulate Time Stamp

From Dev

Difference between time stamp?

Related Related

  1. 1

    mutate new column based on sequence of time stamp in dbplyr

  2. 2

    mysql update based on time stamp in another column

  3. 3

    Python- Can't overwrite first column of .csv file with new time stamp

  4. 4

    failed to save new file with time stamp

  5. 5

    Add a new column based on the current time

  6. 6

    Sorting rows of data frame based on time stamp

  7. 7

    "time_stamp" column too ambiguous

  8. 8

    Sort Excel table based on date in text with time stamp and time zone

  9. 9

    how to count a column by month if the date column has time stamp?

  10. 10

    How to create a new column based on time difference of two columns in Pandas?

  11. 11

    How to add a new column based on the value in the field `time`

  12. 12

    Bin java time stamp by hour/half hour based on date

  13. 13

    SQL Join same table based on time stamp and inventory level

  14. 14

    Searching the relevent rows and adding rows based on time stamp

  15. 15

    Increase value of time"stamp" based on previous content - string

  16. 16

    sql sum a column and also return the last time stamp

  17. 17

    How to create an index on a Time_Stamp column in MySQL?

  18. 18

    Derive date column based on current date and fixed start date

  19. 19

    crosstab query - dynamically derive column headings based on a related table

  20. 20

    Derive date column based on current date and fixed start date

  21. 21

    How to derive a column based on multiple columns values for a single row

  22. 22

    Time stamp in VHDL

  23. 23

    Undefined Time Stamp format?

  24. 24

    Time stamp in hMAC authentication

  25. 25

    Time stamp conversion in php

  26. 26

    Logical delete with a Time stamp

  27. 27

    Angularjs - date/time stamp

  28. 28

    Manipulate Time Stamp

  29. 29

    Difference between time stamp?

HotTag

Archive