I changed your window to be modal. Otherwise the window displays and the SQL is attempted to be run all at once. I'm not sure of the format needed for dates in SQL Server, so you may need to do a little research on that. Copy the SQL statement that outputs to the log and try running it manually in a SQL server window.
nw = New Window( "test", <<modal(),
H List Box(
Text Box( "Start Date" ),
a = Number Edit Box( 0 ),
a << set format( Format( "m/d/y" ) ),
a << set width( 12 ),
a << set( Today() ),
Spacer Box( size( 10, 20 ) ),
Text Box( "End Date" ),
b = Number Edit Box( 0 ),
b << set format( Format( "m/d/y" ) ),
b << set width( 12 ),
b << set( Today() )
),
Spacer Box( size( 1, 20 ) ),
Button Box( "OK",
start_date = Format( a << get, "m/d/y" );
end_date = Format( b << get, "m/d/y" );
)
);
sql_statement = evalinsert("\[
EXEC dbo.listData @Criteria = '
<systemE>
<Data Name="Alarm">
<Columns>
<Column Name="Timestamp"/>
</Columns>
<Where>
<Column Name="Resource" Operator="Like" Value="%a12%"/>
</Where>
<Projects>
<Project Name="abc"/>
</Projects>
</Data>
</systemE>'
,@StartDateTime = '^start_date^'
,@EndDateTime = '^end_date^']\");
show(sql_statement);
// Uncomment the next line to run the command in SQL Server
//dta= Open database("DRIVER=SQL Server; SERVER=XXX; Trusted_connection = Yes", sql_statement);
Other changes - if you want to use the ^xxx^ construct you need to enclose that in evalinsert(). I used the quoting escape characters \[ and ]\ so your SQL statement is a bit cleaner.