Gateway Script to get data into dataset

I am currently using ignition Vision version 8.1.14 and OS windows server 2019.
I have configure tags for history there are around 10 tags.
I have to create a xml file everyday at 12:am for last day with reading of 30mins interval.

What is the best way to set this up.
I was exploring the options to create a gateway script to call for name query( MSSQL) and then get data into dataset and converted into pydataset for creating xml file with custom xml schema. I am experiencing issue with Name query with database field t_stamp fields which required to be converted into datatime format doesn’t appear to be easy way to convert this.
I am not sure if i am going correct path or is there any other way to deal with this.

The t_stamp field for tag history stores the milliseconds since epoch. MSSQL does have a method to parse out that value as a date. Take a look at this Knowledge Base Article: Understanding Tag Historian Timestamps.

I think your approach of going from dataset > pydataset > xml is fine. I would recommend you look at this function as well: system.tag.queryTagHistory().

This function will likely be easier to utilize than writing out a manual query against the tag history tables.

Thanks Kvane,
I manage to get the data using system.tag.queryhistory. this approch was easier than SQL name query.