r/learnSQL • u/anonymous_username18 • Jul 26 '26
Timezone Exercise Help
This is a graded assignment, so for honor code-related things, I really don't need direct answers. I was hoping to get clarification on this SQL assignment, if possible. I've already submitted it, but I'm sort of doubting my answer, and I don't know how to resolve this. I wanted to check whether I should resubmit.
The question states:
TimeStamp Data Types are difficult to work with from one time zone. Therefore, you will enter data from the perspective of different timezones and when you query the data. Create this table:
CREATE table timeexample
(location VARCHAR2(20),
timeWithZone TIMESTAMP WITH TIME ZONE,
timeWithLocalZone TIMESTAMP WITH LOCAL TIME ZONE)
1) Choose 5 different cities, look up their time zone, and INSERT the data.
2) Query all the dataI'm confused what "from the perspective of different timezones" means. So, for Los Angeles, if the time there is 12:05, then I think I would enter '26-Jul-2026 12:05:10 PM -7:00' for the timeWithZone. The part I don't know how to resolve is the timeWithLocalZone: if I enter '26-Jul-2026 12:05:10 PM', won't it just use the system's time zone, instead of actually converting from LA's local zone to my local zone?
In the assignment, I wrote ('Los Angeles', '26-Jul-2026 12:05:10 PM -7:00', '26-Jul-2026 3:05:10 PM') and just manually converted it to what would show up if my session were set to EDT. But I'm sort of worried now that hard coding is not what was intended. I looked it up, and I think I could've used TO_TIMESTAMP_TZ or altered the system session. That wasn't covered in our notes, though, and I'm not sure how far out of the material we're allowed to go. What was the intended approach, and was there another way to do this?
View all comments
Show parent comment
1
u/anonymous_username18 Jul 26 '26
Thanks for your reply - yeah, that's sort of the other thing I wasn't entirely sure about. I don't know if they want us to alter the time zone so that we're in EDT to reflect where our location is, or keep it at UTC. Also, for LA should I have converted it from PST to UTC or from PDT to UTC?