Link to home
Start Free TrialLog in
Avatar of Mat Smith
Mat Smith

asked on

PostgreSQL - now() minus a number of days from variable

Hi Guys,

A quick one for you - In PG sql I want to select the current date minus a number of days as a variable at TIME ZONE 'US/Pacific'.

For instance

 select (now() -  cast( :p as integer) AT TIME ZONE 'US/Pacific');

( :p is a number i.e 2 to be passed when running a query ).

I want the above select to return the current date/time AT TIME ZONE 'US/Pacific' minus a number of days .

How can I achive it please ?
ASKER CERTIFIED SOLUTION
Avatar of johnsone
johnsone
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mat Smith
Mat Smith

ASKER

thanks it worked