crogers111
Technical User
CR XI
SQL
I'm trying to create a formula to get a beginning date for a date range to use as part of a record selection criteria. The beginning date I need is 1 day after the 2nd most recent(maximum) date for a date field. For example.
Record ID Date
001 09/05/2007
002 09/13/2007
003 09/02/2007
004 09/13/2007
09/05/2007 is the 2nd most recent date so I need my beginning date for my range to be 09/06/2007
Can I do this as a formula or does this need to be a SQL expression. I've been trying to get a SQL expression using the following logic but am unsure if this is the correct approach and if so I'm having trouble with the syntax:
select max(date) from table where date < select max(date) from table
SQL
I'm trying to create a formula to get a beginning date for a date range to use as part of a record selection criteria. The beginning date I need is 1 day after the 2nd most recent(maximum) date for a date field. For example.
Record ID Date
001 09/05/2007
002 09/13/2007
003 09/02/2007
004 09/13/2007
09/05/2007 is the 2nd most recent date so I need my beginning date for my range to be 09/06/2007
Can I do this as a formula or does this need to be a SQL expression. I've been trying to get a SQL expression using the following logic but am unsure if this is the correct approach and if so I'm having trouble with the syntax:
select max(date) from table where date < select max(date) from table