no sysdate in postgresql

HI
I noticed that there is no sysdate in postresql
i want to execute following syntax: sysdate-2
i use current_timestamp but receive an error message below

DBD:: PgPP::st execute failed:ERROR: operator does not exist:
timestamp with time zone - integer at char 111
LVL 7
tankergoblinAsked:
Who is Participating?
 
RazvanStefanescuConnect With a Mentor Commented:
Hello,
If you work with dates, you can use integers. If you work with timestamps, interval is better.
You can see below an example where interval gives you some interesting result:
        '2001-02-02'::TIMESTAMP + '1 month'::INTERVAL = '2001-03-02'::TIMESTAMP
        '2001-02-02'::TIMESTAMP + '31 days'::INTERVAL = '2001-03-05'::TIMESTAMP
0
 
psychic_zeroCommented:
Try this:

SELECT now() AS timestamp;

Also can you give your SQL statement and what -2 supposed to do?
0
 
RazvanStefanescuCommented:
Hello,
I think you may use the following code.

BR,
Razvan
now() - interval '2 days'

Open in new window

0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
tankergoblinAuthor Commented:
can i use integer?
now()- integer '2';
0
 
tankergoblinAuthor Commented:
what is the difference btw interval and integer
0
 
RazvanStefanescuCommented:
Hello,
You can use integer. The "interval way" you can use constructions like "interval '1 day' - interval '1 hour'", which is equivalent to "interval '23:00'". It is just easier to read.
0
 
RazvanStefanescuCommented:
Hello,
For more info about date/time operations:

http://developer.postgresql.org/pgdocs/postgres/functions-datetime.html
0
 
tankergoblinAuthor Commented:
so that mean there is no difference between integer and interval?
0
 
earth man2Commented:
sysdate is an Oracle extension to the ANSI standard, use current_date.
select current_date - 2;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.