Concept Flow - Date, time, and timestamp types
Start: Input Date/Time Value
Check Data Type
Date
Store in DB
Retrieve & Format
Output
The flow shows how input values are checked for type (date, time, timestamp), stored, and then retrieved formatted.
CREATE TABLE events ( event_date DATE, event_time TIME, event_timestamp TIMESTAMP ); INSERT INTO events VALUES ('2024-06-01', '14:30:00', '2024-06-01 14:30:00'); SELECT * FROM events;
| Step | Action | Input Value | Data Type Detected | Stored Value | Output on SELECT |
|---|---|---|---|---|---|
| 1 | Create table with date, time, timestamp columns | N/A | N/A | Table schema created | N/A |
| 2 | Insert row with '2024-06-01', '14:30:00', '2024-06-01 14:30:00' | 2024-06-01, 14:30:00, 2024-06-01 14:30:00 | Date, Time, Timestamp | Stored as date, time, timestamp | N/A |
| 3 | Select all rows from events | N/A | N/A | N/A | event_date: 2024-06-01, event_time: 14:30:00, event_timestamp: 2024-06-01 14:30:00 |
| 4 | End of execution | N/A | N/A | N/A | Query complete, all data retrieved |
| Variable | Start | After Insert | After Select | Final |
|---|---|---|---|---|
| event_date | NULL | 2024-06-01 | 2024-06-01 | 2024-06-01 |
| event_time | NULL | 14:30:00 | 14:30:00 | 14:30:00 |
| event_timestamp | NULL | 2024-06-01 14:30:00 | 2024-06-01 14:30:00 | 2024-06-01 14:30:00 |
PostgreSQL date/time types: - DATE stores only date (YYYY-MM-DD) - TIME stores only time (HH:MM:SS) - TIMESTAMP stores date and time (YYYY-MM-DD HH:MM:SS) Insert values must match column type SELECT returns stored values formatted accordingly