Re: OT: using column in an interval

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Stephan Szabo <sszabo@xxxxxxxxxxxxxxxxxxxxx> writes:
> On Thu, 23 Mar 2006, Bradley Kieser wrote:
>> last_backup: timestamp
>> backup_unit: integer - Represents day, week, quarter, annual, etc. The
>> text is stored in backup_code (e.g. 'days', 'months')
>> backup_period: integer - Represents the skip factor.

> CAST( backup_period || ' ' || backup_code AS interval) should give you an
> interval. If the units were constant, I'd say that using integer *
> interval is a better idea, but I think you'd need a function that say took
> backup_unit and gave back an interval of 1 <unit> to make that work, but
> that would possibly be cleaner overall.

This really seems like a case of a poorly chosen representation.  Why
not just have the backup interval as an interval column, ie

last_backup: timestamptz (not timestamp, btw)
backup_interval: interval, can be eg '3 days' or '1 month' or whatever.

Then you can do

WHERE last_backup + backup_interval <= current_timestamp

			regards, tom lane


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux