You have to declare indexes within the table definition. Although indexes are supported (since SQL Server 2014), the CREATE INDEX syntax does not support table variables. So:
DECLARE @TBL TABLE (
ID INT PRIMARY KEY,
FROMDATE DATETIME,
TODATE DATETIME,
INDEX idx_tbl_fromdate (FROMDATE)
);
Here is a db<>fiddle.
EDIT:
If you want a temporary table with an index, use a temporary table. If your version supports this syntax, you can do:
CREATE temp_table (
ID INT PRIMARY KEY,
FROMDATE DATETIME,
TODATE DATETIME,
INDEX idx_tbl_fromdate (FROMDATE)
);
Otherwise create the index separately.