Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread extract year and month
Wed, Nov 5 2008 10:16 AMPermanent Link

"Harry de Boer"
LS,

Given the following query

SELECT DISTINCT id
FROM vh
WHERE  jaar >= extract(year from current_date)
AND maand >= extract(month from current_date)

//jaar, maand (integer fields for year and month) {there is no day or date
field}
2008 12
2009 01
2009 11

The middle record isn't in the resultset. What's the right query for giving
back all the records that equals today or are in the future?

Regards, Harry

Wed, Nov 5 2008 10:38 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Harry

Ahhh one of the perennial favourites.

>SELECT DISTINCT id
>FROM vh
>WHERE jaar >= extract(year from current_date)
>AND maand >= extract(month from current_date)
>
>//jaar, maand (integer fields for year and month) {there is no day or date
>field}
>2008 12
>2009 01
>2009 11
>
>The middle record isn't in the resultset. What's the right query for giving
>back all the records that equals today or are in the future?

Try something along the lines of

SELECT DISTINCT id
FROM vh
WHERE
(jaar * 100) + maand >= (extract(year from current_date) *100 )+extract(month from current_date)

Roy Lambert [Team Elevate]
Wed, Nov 5 2008 11:46 AMPermanent Link

"Robert"

"Harry de Boer" <harry@staaf.nl> wrote in message
news:8FA27D4C-723B-4A56-80EF-768AE888A938@news.elevatesoft.com...
> LS,
>
> Given the following query
>

You want (jaar = year and maand >= month) OR (jaar > year)

Robert

Wed, Nov 5 2008 11:52 AMPermanent Link

"Harry de Boer"
Thanks for the answers. There are indeed more roads to RomeSmile

"Harry de Boer" <harry@staaf.nl> schreef in bericht
news:8FA27D4C-723B-4A56-80EF-768AE888A938@news.elevatesoft.com...
> LS,
>
> Given the following query
>
> SELECT DISTINCT id
> FROM vh
> WHERE  jaar >= extract(year from current_date)
> AND maand >= extract(month from current_date)
>
> //jaar, maand (integer fields for year and month) {there is no day or date
> field}
> 2008 12
> 2009 01
> 2009 11
>
> The middle record isn't in the resultset. What's the right query for
> giving back all the records that equals today or are in the future?
>
> Regards, Harry
>
>

Image