2

I'm working on JBake, and would like to get the year part of the date at which a document was stored.

I know I can get the date by doing

SELECT date FROM post

And OrientDB will return me a java.util.Date.

I know I can also add the year as another field, but I find this data duplication unsatistfying.

So, is it possible to store the date, and to to have the year extracted through some kind of SQL "function" ?

Typically I would love to do

SELECT date, {date.getYear()} FROM post
Riduidel
  • 22,052
  • 14
  • 85
  • 185

1 Answers1

3

You could use the format() function using the SimpleDateFormat syntax:

select date.format('YYYY') from post
Lvca
  • 8,938
  • 2
  • 24
  • 25
wolf4ood
  • 1,939
  • 10
  • 8