SQLite Forum

Getting rid of double DATE()
I have a tcl program where I set a variable like this:
set updateLastBrewed "
    UPDATE selectRandom
    SET    lastUsed    = DATE('now', 'localtime')
    ,      lastUsedIdx = (
        SELECT IFNULL(MAX(lastUsedIdx), 0)
        FROM   selectRandom
        WHERE  lastUsed = DATE('now', 'localtime')
    ) + 1
    WHERE  description = :teaToBrew

This variable I later use to update a table.
But it contains two times:
    DATE('now', 'localtime')

That is maybe less efficient, but I do not care about that. There are two potential problems:
- If I change what I put into lastUsed, I have to change it in both places.
- When the statement is executed just when the day changes, they could give different results.

Is there a neater way to do this?