Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation to sql server - date functions #1885

Closed
eric-fey-hus opened this issue Jul 4, 2023 Discussed in #1884 · 0 comments
Closed

Translation to sql server - date functions #1885

eric-fey-hus opened this issue Jul 4, 2023 Discussed in #1884 · 0 comments
Assignees

Comments

@eric-fey-hus
Copy link

When translating to tsql, the date functions are not converted correctly. For example, it translates "date_part('year', start_date)" to "EXTRACT(year FROM start_date)". But what is needed (correct) "YEAR(start_date)" or "DATEPART(year, start_date)".

Note: EXTRACT is not valid in tsql, SQL Server: https://learn.microsoft.com/en-us/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql?view=sql-server-ver16#GetDateandTimeParts

Discussed in #1884

Originally posted by eric-fey-hus July 4, 2023
Hi,

I want to use the transpile function to translate postgres to sql server. I am using write="tsql", but still get errors. For example, it translates "date_part('year', start_date)" to "EXTRACT(year FROM start_date)". But what I need is "YEAR(start_date)".

How can I define my own "translation" of this in a custom dialect?

Kind regards, Eric

@georgesittas georgesittas self-assigned this Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants