Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6826647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:10:20+00:00 2026-05-26T22:10:20+00:00

In PostgreSQL 8.4 I have a user table: # \d pref_users; Table public.pref_users Column

  • 0

In PostgreSQL 8.4 I have a user table:

# \d pref_users;
                Table "public.pref_users"
   Column   |            Type             |   Modifiers
------------+-----------------------------+---------------
 id         | character varying(32)       | not null
 first_name | character varying(64)       |
 last_name  | character varying(64)       |
 female     | boolean                     |
 vip        | timestamp without time zone |
 mail       | character varying(254)      |

For users who have purchased VIP status I set

update pref_users set vip = now() + interval '6 month' where id='12345';

and later in other scripts I just check for it with

select vip > now() as vip_is_active from pref_users where id='12345';

But there are also 1) users who never purchased VIP (have vip = NULL) and 2) users whose VIP status has already expired (they have vip < now())

My question: as a promotion I’d like to give everyone 1 week VIP status.

I was hoping to do:

update pref_users set vip = max(vip, now()) + interval '1 week';

but max() doesn’t work with timestamps.

Does anybody please have an idea, how to add 1 week to everyone’s vip column?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:10:21+00:00Added an answer on May 26, 2026 at 10:10 pm

    Try this:

    UPDATE pref_users SET vip = GREATEST(vip, now()) + interval '1 week';
    

    max() works with timestamps just fine. But you are mixing query levels in a way that is not feasible. You want the function greatest(), not the aggregate function max().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If a table have a column A which is geometry type,and column B which
I have a postgres database with a user table (userid, firstname, lastname) and a
I'd need advice on following situation with Oracle/PostgreSQL: I have a db table with
I have a query that works on Postgresql 7.4 but not on Postgresql 8.3
I have 2 integer fields in a table user: leg_count and leg_length. The first
I have a name of table or view in PostgreSQL database and need to
I'm using PostgreSQL 8.4.6 with CentOS 5.5 and have a table of users: #
I have a postgresql (v8.4) table with login id and timestamps, and I want
I have a table with 3 columns which looks like this: File User Rating
I have a Django-created tables in PostgreSQL 8.4 database, where one table extends another.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.