Hi,
I want to set the start and end datetime as variable then insert into customsql. in method one below, JMP Alert of converting issue. When I simply hard coded the start and end date as variable, it run without issue. I check both the start and end date type in both method, both are string(). Event the custom sql after substitute into are identical. I cannot find out why the method one not working on date variable. Can someone help?? I really dont want to have to manually change the date everyday. How can I make method 1 works?
method 1 & 2
//method 1 to define start and end date (not working)
sdate= format(today()-inhours(24), "m/d/y"); //method 1
tstart = sdate || " 19:13:01 PM";// method 1
edate= format(today(), "m/d/y"); //method 1
tend = edate || " 12:13:00 AM"; //method 1
//method 2 to define start and end date (working)
tend= "06/19/2023 19:13:01 PM"; //method 2
tstart= "06/19/2023 12:13:00 AM"; //method2
Assign(sql_str, "SELECT t1.[test], CAST(t2.[testplan ] AS INTEGER), bla bla bla
WHERE ( ( ( t1.[end_time] >= &tstart ) AND ( t1.[end_time] <= &tend ) ) ) ;"
);
substitute Into(sql_str, "&tstart", "'"||tstart ||"'");
substitute Into(sql_str, "&tend", "'"||tend ||"'");
dt = New SQL Query (Version(130), connection("mydatabaseinfor"), QueryName("mysqlname" ), CustomSQL(sql_str)) << Run Foreground;