This discussion is archived
3 Replies Latest reply: May 18, 2013 11:42 PM by MK RSS

Need help on my SQL statement

997624 Newbie
Currently Being Moderated
Hello experts,

I need to write a dynamic sql statement which will enable users to pick the date and the BI system will take them 3 months back. I tried 3 months variables I kept getting SQL error then I tried 90 days. Now it keep showing that there is no data which for sure I know its not trure.

This is my statement: +"GL Calendar"."Fiscal Date" >=timestampadd(SQL_TSI_DAY,-90, timestamp'@{ABCcost}{2013-05-16 00:00:00}')AND("GL Calendar"."Fiscal Date">=timestamp'@{ABCcost}{2013-05-16 00:00:00}')+

Anything that Im missing..
  • 1. Re: Need help on my SQL statement
    Veeresh Rayan Journeyer
    Currently Being Moderated
    Use In between statement. When a user select current_date then your in between statement should be like Date in between current_date and Current_date -90 days.

    Mark corrector heplful if it helps.

    Regards,
    Veeresh Rayan
  • 2. Re: Need help on my SQL statement
    997624 Newbie
    Currently Being Moderated
    Rayan,
    I am not sure if I am following you, cause we want to enable the user to pick whatever date and then from there they will get 3 months back and the rest of their info. I tried it didn't work, may be I placed at wrong place

    Can you probably copy my statement above and insert in-between.

    thanks,

    Edited by: 994621 on May 17, 2013 11:28 AM
  • 3. Re: Need help on my SQL statement
    MK Pro
    Currently Being Moderated
    Pls. Use this below --seems you given >= instead of <= on the 2nd condition

    "GL Calendar"."Fiscal Date" >=timestampadd(SQL_TSI_DAY,-90, timestamp'@{ABCcost}{2013-05-16 00:00:00}')AND("GL Calendar"."Fiscal Date" <= timestamp'@{ABCcost}{2013-05-16 00:00:00}')

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points