Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
ekodami
Frequent Visitor

Converting PostGreSQL Date time field at the import using SQL Statement

Hi folks, I am quite new to the forum and hopefully could find some hints.

I am using a PostGreSQL db as data source and would like to convert the table epoch dates upfront at the import. This will be usfefull when performing my incremental refreshes.

In a nutshell, I want the field c6 named as "Last Modified Date" to return the actual date "1713667520" converted to "2024-04-21 2:45:20 AM".

 Here is a sample statement that I used and the error message :

= Value.NativeQuery(PostgreSQL.Database("xx.xxx.xx.xxx:xxxxx", "xxxxxxxxx"), "SELECT #datetime(1970, 1, 1)# + (c6/86400) AS ""Modified Date"" FROM t1111", null, [EnableFolding=true])

And here is the error message returned:

DataSource.Error: PostgreSQL: 42883: function datetime(integer, integer, integer) does not exist
Details:
DataSourceKind=PostgreSQL
DataSourcePath=10.166.33.144:48500;saputo_tp1_ar
Message=42883: function datetime(integer, integer, integer) does not exist
ErrorCode=-2147467259
NativeError=42883

Pls let me know if more details

Thank you

2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

Instead of #datetime(1970, 1, 1)# 

 

use DATE('1970-01-01')

View solution in original post

ekodami
Frequent Visitor

Worked. Wonderful! Thanks.. much appreciated

View solution in original post

2 REPLIES 2
ekodami
Frequent Visitor

Worked. Wonderful! Thanks.. much appreciated

lbendlin
Super User
Super User

Instead of #datetime(1970, 1, 1)# 

 

use DATE('1970-01-01')

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.