tia97
tia97

Reputation: 350

Date conversion - ISO?

I was given this line to add to my query from a co-worker but I'm not understanding what it is doing. Unfortunately he is offline and on vacation so I couldn't ask him directly. I ran the query with and without this line and I don't see the difference.

g.fromdos > replace(char(current date - 10 days, iso), '-', '')

Upvotes: 1

Views: 56

Answers (1)

Jonathan Leffler
Jonathan Leffler

Reputation: 753615

Making educated guesses, since the DBMS is not specified:

  • The current date - 10 days produces the date 10 days ago.
  • The char(current date - 10 days, iso) formats the date in the ISO 8601 format, which looks like "2014-12-13" (given that today is 2014-12-23).
  • The replace operation replaces the dashes with nothing, yielding "20141213".
  • So, the comparison checks whether the g.fromdos value compares larger than "20141213".

Without knowledge of the type of g.fromdos, it's not possible to say whether the comparison is done as numbers or strings.

Upvotes: 2

Related Questions