I want to found the count of days remaining in the year in SAQL .

q= foreach q generate daysbetween(toDate(date_to_epoch(year_start_day))-now()) as 'daysRemaining'

I want apply formula 365-now() in saql

Please help me !!


You could do something like this to calculate each date's distance to the end of the year...

q = foreach q generate 
    toDate('DATA-DATE-FIELD', "yyyy-MM-dd"), 
    year_last_day(toDate('DATA-DATE-FIELD', "yyyy-MM-dd"))
  ) as 'EOY Distance';

I just tested it and it seems to work out:

Date       EOY Distance
2014-12-30 1
2014-12-31 0


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.