● videoExtraction
Validating the Master Plan

Unlock PostgreSQL Fundamentals
2 hours of SQL video using NASA's Cassini data. See why developers become data pros.
SECTION
Extraction
NEXT UP
Creating a Proper Import Script
COURSE
PostgreSQL Fundamentals
28 lessons
About this lesson
The date information in our imported data looks a little strange, with a timestamp that's formatted as year-dayofyear, a duration, and a weird column named date that's formatted in a pretty simplistic way.
We can validate that the timestamp format won't cause problems by running a simple query, casting it to an ISO string:
<span class="hljs-keyword">select</span> start_time_utc::<span class="hljs-type">timestamp</span> <span class="hljs-keyword">from</span> csvs.master_plan;
That will throw if the conversion won't work.
You can reconcile two fields of data by running a simple comparison. The trick, however, is to be sure they're the same type, and we can do that by casting (::) both to a date:
<span class="hljs-keyword">select</span> start_time_utc <span class="hljs-keyword">from</span> csvs.master_plan
<span class="hljs-keyword">where</span> start_time_utc::<span class="hljs-type">date</span> <span class="hljs-operator"><></span> <span class="hljs-type">date</span>::<span class="hljs-type">date</span>;
Unlock PostgreSQL Fundamentals
2 hours of SQL video using NASA's Cassini data. See why developers become data pros.