From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

obtain a timestamp from database connectivity toolkit

hello!

 

I would like to get a timestamp with the database connectivity toolkit.

 

from sqlserver, my datetime is written like this:

format: datetime

content: 2016-01-01 00:00:00.000

 

The VI I'm using looks like this:

 

Sans titre.png

the typedef cluster entering into the function "database variant to data" has the properties below

 

 

Sans titre.png

 

but when I'm launching it, the function " the function "database variant to data" returns this error, translation "datatype in the variant is incompatible with the datatype at the input of the function

Sans titre.png

 

I f I edit my typedef and replace string from datetime, everithing is working, the boleans return the correct values, but  time returned in the string is just date, not time.

can you help me?

 

 

Pierre FCentum TNS, Grenoble
Certified LabVIEW Associated Developer
0 Kudos
Message 1 of 3
(3,667 Views)

Hello,

 

It seems the datatype datatime is not a string, it's a specific datatype for LabVIEW.

In my point of view, you have to use a function to convert the datatime in tring and send a string to the database (see example bellow)

String is a classing datatype easily shared by different programming language.

If you want to change the parameter of the time in the string, refer to the help of the function.

 

Best Regards,

Guillaume D
0 Kudos
Message 2 of 3
(3,590 Views)

The datatypes need to match exactly or they will not cast correctly.

 

You could use this scripting VI I wrote some time ago to have LabVIEW create a cluster for you based on the elements of a specified table.

 

You can save the cluster as a typedef and then use that the create an empty array to use as the input to the Database Variant to Data function.

 

https://decibel.ni.com/content/docs/DOC-19512

 

 You may find that the datetime is being stored in your DB as a string, which means you would need to convert it yourself from string to datetime.

 


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 3 of 3
(3,580 Views)