-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdate.sql
37 lines (24 loc) · 771 Bytes
/
date.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
-- Active: 1708953613720@@127.0.0.1@5432@ph
--see time ZONE
-- show timezone
-- see timestamp
-- select now()
-- create a table with date
-- create table timeZ(ts TIMESTAMP without TIME zone ,tsz timestamp with time zone);
-- insert imto TABLE
-- insert into timeZ values('2024-01-12 10:45:05','2024-01-12 10:45:05')
-- see today's date
-- select CURRENT_DATE
-- select now()::date
-- see time
-- select now()::time
-- date formet function
-- select to_char(now(),'DDD')
-- go back one YEAR
-- select current_date -interval '1 month'
-- caculate age using date
-- select age(CURRENT_DATE,'1996-07-29')
-- Calculate age from table data
-- select *,age(CURRENT_DATE,dob) from students;
-- get year from date
-- select extract(year from '2021-05-21'::date)