Hello Statalist, I apologize for posting a date/time question, but I have been unable to find my problem (or the answer).


I have a variable that is a date and time in the format MM/DD/YY HH:MM. It is also a string variable.

des record_dttm

storage display value
variable name type format label variable label
--------------------------------------------------------------------------------------------------------------------------------
record_dttm str14 %14s


list record_dttm in 1/5

+----------------+
| record_dttm |
|----------------|
1. | 10/20/18 11:53 |
2. | 10/20/18 15:14 |
3. | 10/27/17 22:00 |
4. | 10/27/17 22:00 |
5. | 10/27/17 6:30 |
+----------------+

I cannot for the life of me figure out how to create a new variable without the HH:MM.

Here is my code:

. gen tx_day = date(record_dttm, "DDMMYYHHMM")
(6,284 missing values generated)

I have tried every iteration of DMYHHMM that can think of and still not able to format the variable. Again, I apologize for posting a simple date and time issue on this forum.

Best, Micah