I want to calculate the days between two dates from 2009 to till now in Flex Wave analytics.

I am referring this link(https://developer.salesforce.com/docs/atlas.en-us.bi_dev_guide_saql.meta/bi_dev_guide_saql/bi_saql_functions_date.htm) but it is not working for me.

I have a query--

q = load "0Fb6F000000HTubSAG/0Fc6F000000HbrGSAS";
q = group q by ('CreatedDate_Year', 'CreatedDate_Month');
q = foreach q generate 'CreatedDate_Year' + "~~~" + 'CreatedDate_Month' as 'CreatedDate_Year~~~CreatedDate_Month', unique('Id') as 'unique_Id';
q = order q by 'CreatedDate_Year~~~CreatedDate_Month' asc;
q = limit q 2000;

where to put the date function in this?

Thanks Tanushree Roy


The response provided is not wrong, however when updating the generate statement in the SAQL editor the statement should be:

    generate daysBetween(toDate('CreatedDate_Year'+"-"+'CreatedDate_Month'+"-"
+'CreatedDate_Day', "yyyy-MM-dd"),now()) as age;
  • q foreach q generate daysBetween(toDate('CreatedDate_Year'+"-"+'CreatedDate_Month'+"-"+'CreatedDate_Day', "yyyy-MM-dd"),now()) as age – Allison Nov 14 '17 at 21:43
  • 1
    Please edit your post to add any information you wish. Comments are not designed for that purpose. – Adrian Larson Nov 14 '17 at 21:52
    q = foreach q generate daysBetween
(toDate('CreatedDate_Year'+ \"-\"+ CreatedDate_Month + \"-\" 
+ CreatedDate_Day, \"yyyy-MM-dd\"),now()) as age

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.