All Forums Database
nambir 7 posts Joined 03/16
03 Mar 2016
need to test a query using three diff dates

Hi,

i want to test my query on three different dates .Either it takes the dates during run time or pick three defined dates.

I am not sure if recursive will help in here as I have not used it before.

Can someone help me on this?

Thanks

dnoeth 4628 posts Joined 11/04
03 Mar 2016

It's hard to help without knowing what you try to do. 
You need to add more details including some sample data and expected result...

Dieter

Adeel Chaudhry 773 posts Joined 04/08
06 Mar 2016

SELECT CURRENT_DATE, CURRENT_DATE - 1, CURRENT_DATE - 2

-- If you are stuck at something .... consider it an opportunity to think anew.

nambir 7 posts Joined 03/16
09 Mar 2016

I want to run the following query with three random dates since last 6 months
 

SEL File_Id

FROM  databaseschema.tablebame

where cast (Accnt_Start_Dttmz as date) = '2016-01-21 '

 
now i want the dates to change everytime i run this query..like parameterised it somehow

dnoeth 4628 posts Joined 11/04
09 Mar 2016

You can use CURRENT_DATE - RANDOM(0, 182) to get a random date

Dieter

nambir 7 posts Joined 03/16
09 Mar 2016

can you explain a bit more
plus what if I want to choose dates myself at the time of running.
 

dnoeth 4628 posts Joined 11/04
09 Mar 2016

You simply use this in WHERE.
But if you choose a date it's not random :)
You must explain more...

Dieter

yuvaevergreen 93 posts Joined 07/09
11 Mar 2016

If its a simple query, put it in a macro and parameterize the input date.

You must sign in to leave a comment.