Search this site
Embedded Files
intdescod
  • Home
  • My Note
    • Linux
    • Node js
    • Docker
    • PostgreSQL
    • Hadoop
    • Python
    • JavaScript
    • Express
    • ShellScript
    • Github
    • Next js
    • Node-Red
  • Full Projects
    • bot_telegram
  • About me
intdescod
  • Home
  • My Note
    • Linux
    • Node js
    • Docker
    • PostgreSQL
    • Hadoop
    • Python
    • JavaScript
    • Express
    • ShellScript
    • Github
    • Next js
    • Node-Red
  • Full Projects
    • bot_telegram
  • About me
  • More
    • Home
    • My Note
      • Linux
      • Node js
      • Docker
      • PostgreSQL
      • Hadoop
      • Python
      • JavaScript
      • Express
      • ShellScript
      • Github
      • Next js
      • Node-Red
    • Full Projects
      • bot_telegram
    • About me

list contents

PostgreSQL

Date & Time

Date

cetak tanggal tertentu yang sudah lewat


select

now()::date "Current Date",

to_char(now() - interval '1 year','yyyy-mm-dd') "1 year Before",

to_char(now() - interval '1 month','yyyy-mm-dd') "1 Month Before",

to_char(now() - interval '1 day','yyyy-mm-dd') "1 day Before"


Current Date|1 year Before|1 Month Before|1 day Before|

------------+-------------+--------------+------------+

  2024-09-11|2023-09-11   |2024-08-11    |2024-09-10  |

cetak tanggal tertentu yang akan datang


select

now()::date "Current Date",

to_char(now() - interval '-1 year','yyyy-mm-dd') "1 year Later",

to_char(now() - interval '-1 month','yyyy-mm-dd') "1 Month Later",

to_char(now() - interval '-1 day','yyyy-mm-dd') "1 day Later"


Current Date|1 year Later|1 Month Later|1 day Later|

------------+------------+-------------+-----------+

  2024-09-11|2025-09-11  |2024-10-11   |2024-09-12 |

cetak sisa hari & tanggal akhir bulan


SELECT

now()::date AS "Current Date",

TO_CHAR(now(), 'FMDay') "Current Day",

(date_trunc('month', now()) + interval '1 month - 1 day')::date AS "End of Month",

(date_trunc('month', date (to_char(now(),'yyyy-mm-01'))) + interval '1 month - 1 day')::date - now()::date "the rest of the days";


Current Date|Current Day|End of Month|the rest of the days|

------------+-----------+------------+--------------------+

  2025-05-26|Monday     |  2025-05-31|                   5|


Google Sites
Report abuse
Page details
Page updated
Google Sites
Report abuse