Subject Re: [firebird-support] Re: Order by (Date minus Date)
Author Helen Borrie
At 06:38 PM 21/01/2008, you wrote:
>Gosh, you're right. It does work. My bad. On to the next question,
>then. The following query really doesn't work.
>
>SELECT P.PeriodName, ('2008/01/21' - P.StartDate) AS PeriodLength
>FROM Periods P
>ORDER BY 2 DESC
>
>Could you help me get this working with date literals?

You can cast date literals, as long as they have a legal format. Your example should work if you cast it:

SELECT
P.PeriodName,
(CAST('2008/01/21' AS DATE) - P.StartDate) AS PeriodLength
FROM Periods P
ORDER BY 2 DESC

./hb