LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timestamp from SQL to graph

Hello,

 

is there a way to read a time stamp from a SQL database into a graph. So when I right click onto the graph and export to Excel, I would get the time as well? This would be some easy way to just get the times for a certain snapshot while the time keeps rolling by?

 

Cheers,

 

Steffen

timestamp graph.jpg

0 Kudos
Message 1 of 8
(4,318 Views)

Hi there,

 

Could you provide information on the database table setup?

 

What database server you are specifically using as well?

 

I have MySQL, MariaDB and also SQL. I could potentially setup a similar system quite quickly, it would also be helpful if you could provide the VI for proficiency.

 

Thanks,

 

Ed

0 Kudos
Message 2 of 8
(4,209 Views)

Hi,

 

So with your current code, it should be that when you export to Excel, you get 4 columns - the first two being something like 3E9? This is a LabVIEW timestamp, formatted as a double.

 

Excel can also take double inputs and format them as timestamps, but it doesn't have the same offset, so some conversion would be necessary if that was your goal. A link describing this issue is here.

 

Does that help you?


GCentral
0 Kudos
Message 3 of 8
(4,207 Views)

Also just noticed that the timestamps merged together and make up waveforms... That's quite odd considering that the data comes from SQL and there is a Get Date/Time in Seconds?

 

Could you elaborate further on the real world side of things, what is this data and why do you use Get Date/Time in Seconds when presumably the data was captured sometime in the past?

 

Additionally, while "get snapshot" is quite convenient and is discussed in Core 2, I would recommend instead to have an architecture which have this functionality. It will make for adding other functionalities later easy. Core 2 covers this it starts by talking about architectures from lesson 2, mentions snapshots in lesson 4 and then shows a more flexible method in lesson 5 by capturing and storing the data programmatically on a user button click.

 

However it is not obvious where your current issue lies, I honed in on the database side of things as I noticed you converted the database variant to string. This assumes it is stored in this format when usually would it not be and in fact timestamp. The example linked below shows an architecture I would recommend and also the conversion method in the VI var2data.vi:

 

http://forums.ni.com/t5/Example-Program-Drafts/DataBase-Gathering-Information-in-a-Specific-Date-Tim...

 

Please provide the requested information but also more clarity on what the current issue is.

 

Thanks,

 

Ed

0 Kudos
Message 4 of 8
(4,200 Views)

ok, the plan is, data is logged in one place and put into a MySQL data base including a time stamp, see connect to MySQL vi. Somewhere else there will be several front ends that get data from that data base. These will read the last time stamp. Time stamp is indexed in MySQL.

So if something exciting is happening on the graph, one could just export that section to Excel vie right click. Then a time stamp would be handy.

The solution here would work, if the time does not drift off, as the starting point in the receiver is then used to read every 1000ms. If the sender takes 1000ms and a bit, then slowly there will be a problem. Wait until next multiple ms in both vis does not work, as the receiver starts training off and reads identical values at times,

0 Kudos
Message 5 of 8
(4,186 Views)

@cbutcher,

 

yes, that works as well.Just have to set y axis to more than 6 digits behind comma. There are 10 hrs missing for Melbourne time though.

0 Kudos
Message 6 of 8
(4,167 Views)

@Steffen01 wrote:

@cbutcher,

 There are 10 hrs missing for Melbourne time though.


If you mean time difference, you might want a different time format specifier. I think %X is the locale-specific time and %z is the difference between GMT and the location time. I'm not sure if you can use those to get what you need.


GCentral
0 Kudos
Message 7 of 8
(4,163 Views)

either this or subtract another 36 000 s in winter and 28 800 in summer

The other problem is, the current time is form the computer, where the SQL reader is running. But the computer, where the SQL database sits, could be a few minutes off. So better get the timestamp, that has been set in the SQL database.

Then again, thats hoe I did it. Can upload it tonight

0 Kudos
Message 8 of 8
(4,154 Views)