gpt-3.5-turbo-0613· openai
Suzhen/CodeChat
from c# i have a DateTimeOffset today = DateTimeOffset.UtcNow.Date; long unixTimestamp =…
- User
from c# i have a
DateTimeOffset today = DateTimeOffset.UtcNow.Date; long unixTimestamp = today.ToUnixTimeSeconds();i need to see that on postgres to check if other dates stores as integer are the same day, ignoring the timestamp
- Assistant
In PostgreSQL, you can use the
to_timestamp()andextract(epoch from ...)functions to convert the integer value to a timestamp and extract the date portion respectively. Here's an example query:SELECT * FROM your_table WHERE to_timestamp(your_column_name)::date = to_timestamp(your_unix_timestamp)::date;Replace
your_tablewith the name of your table andyour_column_namewith the column name storing the integer dates. Also, replaceyour_unix_timestampwith the specific integer value you want to check against. This query will return all rows where the date portion of the stored timestamp is the same as the date extracted from the provided Unix timestamp, ignoring the time portion.