Does TDengine support timestamp by nanosecond? - database

Does TDengine support timestamp by nanosecond ? What should I do if I want to use it ?

You could try specifying the timestamp precision when you create the DB, for example:
create database db precision 'ns';

Related

how to resolve the problem that TDengine database has no function that converts the date format

how to resolve the problem that TDengine database has no function that converts the date format?
I want to know the my data belong to which year, month, and day.
but not a specific timestamp
you can use TDengine database's "timetruncate" function to get the format you need like:
select timetruncate(ts,1d),value from tables.

Is TDengine SQL support do caculate between columns and tag?

I was using TDengine for some times,and I tried to caculate some rate through the tags and columns. The follow is my table structure:
create table p(ts timestamp,voltag int)tags(nominal_voltage int);
Any calculate SQL is
select voltag/nominal_voltage from p;
but an I got the error bellow:
DB error: invalid operation: tag columns can not be used in arithmetic
expression (0.001368s)
My TDengine Version is: version: 2.4.0.12.
Does some know is there any way to calculate the rate. Or is there any method that TDengine supports for this situation.
Sorry, the arithmetic expression is not supported for tag in TDengine. Tag is just a flag that identifies the data table.
I think I can store the tag value as a normal column, and then I can do arithmetic calucate between them
TDengine 2.x does not support calculation between column and tag. It will be improved in a 3.x re-designation.

SQL Server: Using date in ISO 8601 format in WHERE clause

In SQL Server 2014 I tried the following query:
select *
from MyTable
where StartDate = '2021-12-31T00:00:00.0000000'
I get this error:
Msg 295, level 16, state 3, row 3
Conversion failed when converting character string to smalldatetime data type.
As far as I can tell this string is in ISO 8601 format, so it should be accepted by SQL Server (I read that this should actually be the preferred format when passing dates to SQL Server).
Is there a way to tell SQL Server to accept this format?
Please note: this query is actually generated by Linq in an Entity Framework Core DataContext, so I can't change the query itself in any way.
Older versions of EF Core did not support smalldatetime.
This was fixed in version 2.2.0 in 2018.
Update your EF Core version to something more recent than 2.2.0.
If you are using a modern EF Core version, then you should file this as a regression bug.
But better yet: don't use smalldatetime in your database design in the first place. Use datetime2(n) or some other appropriate type instead.
There is no good reason for using smalldatetime in a new database design (nor other types like text, ntext, image, timestamp, etc)
And you should be able to run ALTER TABLE to change the column type to datetime2(7) with no compatibility issues unless something else is really horribly designed in your system, in which case you should fix that.
If you really need to expose data as smalldatetime because of some horrible and opaque, but business-critical, binary that you can't rebuild then you can add a VIEW, SYNONYM and other shims to transparently convert datetime2(n) to smalldatetime while the rest of the system can live in modernity.

TimeStamp Conversion From HexaDecimal

How can I convert a hexadecimal timestamp to date time in SQL server.
I tried Cast/Convert but it throws error.
Regards,
Rahul
You can't. "The Transact-SQL timestamp data type is different from the timestamp data type defined in the SQL-2003 standard. The SQL-2003 timestamp data type is equivalent to the Transact-SQL datetime data type." and "The timestamp data type is just an incrementing number and does not preserve a date or a time. To record a date or time, use a datetime data type." Source
And also: "The timestamp syntax is deprecated. This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature." Source

What is the SQL Server timestamp equivalent in sqlce?

I have some data with a timestamp in SQL Server, I would like to store that value in sqlce with out getting fancy to compare the two values.
What is the SQL Server timestamp equivalent in sqlce?
Timestamp is from MS Docs
timestamp is a data type that exposes automatically generated binary numbers, which are guaranteed to be unique within a database. timestamp is used typically as a mechanism for version-stamping table rows. The storage size is 8 bytes.
This value makes no sense outside the database it was created in. Thus I don't see how it can be converted.
In a non Sybase/ SQL Server database I would use a version number or last updated column
AS of Sql Compact 3.5, there is support for timestamps, per MSDN:
SQL Server Compact implements the
timestamp (rowversion) data type. The
rowversion is a data type that exposes
automatically generated binary
numbers, which are guaranteed to be
unique in a database. It is used
typically as a mechanism for
version-stamping table rows.
Ok the timestamp is a varbinary that auto generates. So to copy a time stamp you need a varbinary field.

Resources