Skip to content
Advertisement

How to query a database table which store the datetime values as biginit

I am working on a third party SQL Server database, and inside the following table they store the RESPONSETIME as bigint as follows:

enter image description here

Now I want to get the records which have their RESPONSETIME between 22-March till 31-March, something as follow:

Currently when I run the above I will get this error:

Error converting data type varchar to bigint.

So is there a way to have things working well for me?

Thanks

Now the 3rd party provide this function to convert the long into the related data:-

But I am not sure how I can add this function to my SQL?

Advertisement

Answer

Rather than converting the responsetime to a date to compare, you should do the reverse and convert your date to the same format. This will allow SQL Server to seek directly to the relevant rows using a suitable index on ResponseTime.

Assuming the date is @yourdate and assuming the integer value is milliseconds since 01/01/1970 then the following should hopefully work

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement