Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • 2
    Please explain what each statement is doing. You can't assume that those that know Postgres also know SQL Server. But TO_CHAR(TO_CHAR(YEAR(Date))||'Y') doesn't look at all like T-SQL Commented Jun 21, 2021 at 17:15
  • 2
    Unrelated to your problem, but: Postgres 9.5 is no longer supported you should plan an upgrade as soon as possible. Commented Jun 21, 2021 at 17:16
  • @a_horse_with_no_name sure..these are all conversion statements in sql to other data types based on case statements basis..just looking for equivalent postgres ones..replacements as there is no to_char(year) in postgres nor convert..thanks Commented Jun 21, 2021 at 17:59
  • Well "conversion into another SQL type" is done with cast() in Postgres. Commented Jun 21, 2021 at 18:27
  • 1
    For one: there is no to_char() in SQL Server. And TO_CHAR(TO_CHAR(YEAR(Date))||'Y') makes no sense to begin with and SQL Sever doesn't use the standard || concatenation operator - so that can't be your SQL Server code. But if Date is a column with the data type date then I guess(!) you might be looking for to_char("date", 'YYYY"Y"') in Postgres. Commented Jun 22, 2021 at 5:40