How to create a rule on QGIS to show only features that have last week as date?
up vote
2
down vote
favorite
Basically I have a PostGIS layer with a date column.
I only need to show features that have the last week as a value in the date column. How to achieve this?
Unfortunately now() - 1 week
doesn't seem to work
qgis postgis postgresql style
add a comment |
up vote
2
down vote
favorite
Basically I have a PostGIS layer with a date column.
I only need to show features that have the last week as a value in the date column. How to achieve this?
Unfortunately now() - 1 week
doesn't seem to work
qgis postgis postgresql style
2
Do you mean last week (somewhen between mon and sunday last week) or exactly 7 days past?
– markgraeflerland
Nov 9 at 12:23
@markgraeflerland exactly 7 days, thought that was the definition of a week
– Luffydude
Nov 9 at 13:50
@Luffydude not necessarily. There are several definitions (any 7 days, Monday-Sunday, or Sunday-Saturday (and other start-end days), plus partial weeks for the 1st or last week of the year). The intended usage in terms of weeks or days is relevant ex: Monday of week 1 is "last week" from Sunday of week 2, but they are more than 7 days apart.
– JGH
Nov 9 at 14:23
@Luffydude: If I have a feature with monday in the date column than a feature created last friday would also be a feature created last week, but not neccessarily 7 days ago. That's the reason why I try to find out what your talking about
– markgraeflerland
Nov 9 at 14:26
Sure guys, make sense. For the purpose of this exercise I would need something like 7 days then
– Luffydude
Nov 12 at 9:42
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
Basically I have a PostGIS layer with a date column.
I only need to show features that have the last week as a value in the date column. How to achieve this?
Unfortunately now() - 1 week
doesn't seem to work
qgis postgis postgresql style
Basically I have a PostGIS layer with a date column.
I only need to show features that have the last week as a value in the date column. How to achieve this?
Unfortunately now() - 1 week
doesn't seem to work
qgis postgis postgresql style
qgis postgis postgresql style
edited Nov 9 at 13:49
asked Nov 9 at 11:50
Luffydude
711917
711917
2
Do you mean last week (somewhen between mon and sunday last week) or exactly 7 days past?
– markgraeflerland
Nov 9 at 12:23
@markgraeflerland exactly 7 days, thought that was the definition of a week
– Luffydude
Nov 9 at 13:50
@Luffydude not necessarily. There are several definitions (any 7 days, Monday-Sunday, or Sunday-Saturday (and other start-end days), plus partial weeks for the 1st or last week of the year). The intended usage in terms of weeks or days is relevant ex: Monday of week 1 is "last week" from Sunday of week 2, but they are more than 7 days apart.
– JGH
Nov 9 at 14:23
@Luffydude: If I have a feature with monday in the date column than a feature created last friday would also be a feature created last week, but not neccessarily 7 days ago. That's the reason why I try to find out what your talking about
– markgraeflerland
Nov 9 at 14:26
Sure guys, make sense. For the purpose of this exercise I would need something like 7 days then
– Luffydude
Nov 12 at 9:42
add a comment |
2
Do you mean last week (somewhen between mon and sunday last week) or exactly 7 days past?
– markgraeflerland
Nov 9 at 12:23
@markgraeflerland exactly 7 days, thought that was the definition of a week
– Luffydude
Nov 9 at 13:50
@Luffydude not necessarily. There are several definitions (any 7 days, Monday-Sunday, or Sunday-Saturday (and other start-end days), plus partial weeks for the 1st or last week of the year). The intended usage in terms of weeks or days is relevant ex: Monday of week 1 is "last week" from Sunday of week 2, but they are more than 7 days apart.
– JGH
Nov 9 at 14:23
@Luffydude: If I have a feature with monday in the date column than a feature created last friday would also be a feature created last week, but not neccessarily 7 days ago. That's the reason why I try to find out what your talking about
– markgraeflerland
Nov 9 at 14:26
Sure guys, make sense. For the purpose of this exercise I would need something like 7 days then
– Luffydude
Nov 12 at 9:42
2
2
Do you mean last week (somewhen between mon and sunday last week) or exactly 7 days past?
– markgraeflerland
Nov 9 at 12:23
Do you mean last week (somewhen between mon and sunday last week) or exactly 7 days past?
– markgraeflerland
Nov 9 at 12:23
@markgraeflerland exactly 7 days, thought that was the definition of a week
– Luffydude
Nov 9 at 13:50
@markgraeflerland exactly 7 days, thought that was the definition of a week
– Luffydude
Nov 9 at 13:50
@Luffydude not necessarily. There are several definitions (any 7 days, Monday-Sunday, or Sunday-Saturday (and other start-end days), plus partial weeks for the 1st or last week of the year). The intended usage in terms of weeks or days is relevant ex: Monday of week 1 is "last week" from Sunday of week 2, but they are more than 7 days apart.
– JGH
Nov 9 at 14:23
@Luffydude not necessarily. There are several definitions (any 7 days, Monday-Sunday, or Sunday-Saturday (and other start-end days), plus partial weeks for the 1st or last week of the year). The intended usage in terms of weeks or days is relevant ex: Monday of week 1 is "last week" from Sunday of week 2, but they are more than 7 days apart.
– JGH
Nov 9 at 14:23
@Luffydude: If I have a feature with monday in the date column than a feature created last friday would also be a feature created last week, but not neccessarily 7 days ago. That's the reason why I try to find out what your talking about
– markgraeflerland
Nov 9 at 14:26
@Luffydude: If I have a feature with monday in the date column than a feature created last friday would also be a feature created last week, but not neccessarily 7 days ago. That's the reason why I try to find out what your talking about
– markgraeflerland
Nov 9 at 14:26
Sure guys, make sense. For the purpose of this exercise I would need something like 7 days then
– Luffydude
Nov 12 at 9:42
Sure guys, make sense. For the purpose of this exercise I would need something like 7 days then
– Luffydude
Nov 12 at 9:42
add a comment |
2 Answers
2
active
oldest
votes
up vote
5
down vote
accepted
If you want to completly filter out the records, i.e. set a filter at the layer level, you can use the Postgres function to create an interval:
"update_date" >= (CURRENT_DATE - interval '1 week')
If you want to style/label the records differently, you can use the age
function to return a timespan between two dates, and the week
function to extract the number of weeks.
To get result from last week, the rule filter would be:
week(age(now(),"update_date"))<=1
Worked like a charm. Thanks dude
– Luffydude
Nov 12 at 9:46
add a comment |
up vote
3
down vote
You should use
NOW() - INTERVAL '1 week'
instead of
now() - 1 week
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
If you want to completly filter out the records, i.e. set a filter at the layer level, you can use the Postgres function to create an interval:
"update_date" >= (CURRENT_DATE - interval '1 week')
If you want to style/label the records differently, you can use the age
function to return a timespan between two dates, and the week
function to extract the number of weeks.
To get result from last week, the rule filter would be:
week(age(now(),"update_date"))<=1
Worked like a charm. Thanks dude
– Luffydude
Nov 12 at 9:46
add a comment |
up vote
5
down vote
accepted
If you want to completly filter out the records, i.e. set a filter at the layer level, you can use the Postgres function to create an interval:
"update_date" >= (CURRENT_DATE - interval '1 week')
If you want to style/label the records differently, you can use the age
function to return a timespan between two dates, and the week
function to extract the number of weeks.
To get result from last week, the rule filter would be:
week(age(now(),"update_date"))<=1
Worked like a charm. Thanks dude
– Luffydude
Nov 12 at 9:46
add a comment |
up vote
5
down vote
accepted
up vote
5
down vote
accepted
If you want to completly filter out the records, i.e. set a filter at the layer level, you can use the Postgres function to create an interval:
"update_date" >= (CURRENT_DATE - interval '1 week')
If you want to style/label the records differently, you can use the age
function to return a timespan between two dates, and the week
function to extract the number of weeks.
To get result from last week, the rule filter would be:
week(age(now(),"update_date"))<=1
If you want to completly filter out the records, i.e. set a filter at the layer level, you can use the Postgres function to create an interval:
"update_date" >= (CURRENT_DATE - interval '1 week')
If you want to style/label the records differently, you can use the age
function to return a timespan between two dates, and the week
function to extract the number of weeks.
To get result from last week, the rule filter would be:
week(age(now(),"update_date"))<=1
answered Nov 9 at 12:10
JGH
11.4k21133
11.4k21133
Worked like a charm. Thanks dude
– Luffydude
Nov 12 at 9:46
add a comment |
Worked like a charm. Thanks dude
– Luffydude
Nov 12 at 9:46
Worked like a charm. Thanks dude
– Luffydude
Nov 12 at 9:46
Worked like a charm. Thanks dude
– Luffydude
Nov 12 at 9:46
add a comment |
up vote
3
down vote
You should use
NOW() - INTERVAL '1 week'
instead of
now() - 1 week
add a comment |
up vote
3
down vote
You should use
NOW() - INTERVAL '1 week'
instead of
now() - 1 week
add a comment |
up vote
3
down vote
up vote
3
down vote
You should use
NOW() - INTERVAL '1 week'
instead of
now() - 1 week
You should use
NOW() - INTERVAL '1 week'
instead of
now() - 1 week
answered Nov 9 at 12:12
Asad Abbas
704218
704218
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f302001%2fhow-to-create-a-rule-on-qgis-to-show-only-features-that-have-last-week-as-date%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Do you mean last week (somewhen between mon and sunday last week) or exactly 7 days past?
– markgraeflerland
Nov 9 at 12:23
@markgraeflerland exactly 7 days, thought that was the definition of a week
– Luffydude
Nov 9 at 13:50
@Luffydude not necessarily. There are several definitions (any 7 days, Monday-Sunday, or Sunday-Saturday (and other start-end days), plus partial weeks for the 1st or last week of the year). The intended usage in terms of weeks or days is relevant ex: Monday of week 1 is "last week" from Sunday of week 2, but they are more than 7 days apart.
– JGH
Nov 9 at 14:23
@Luffydude: If I have a feature with monday in the date column than a feature created last friday would also be a feature created last week, but not neccessarily 7 days ago. That's the reason why I try to find out what your talking about
– markgraeflerland
Nov 9 at 14:26
Sure guys, make sense. For the purpose of this exercise I would need something like 7 days then
– Luffydude
Nov 12 at 9:42