LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

date format conversion from MySQL

Hi my dear friends. I have some problem with the date format.
I am using MySQL version 3, LabSQL and Labview7.1

In the MySQL, the date format reads as 2006-12-18 14-51-25

while, when querying in Labview, it reads 18-Dec-06 14-51-25.

So when using this date (18-Dec-06 14-51-25) to query further. I got problems as MySQL does not recognise this format.
How can I convert 18-Dec-06 to 2006-12-18?
It might sound easier to change but for the year how do I change it to proper 2006, not 1906?

Your solution will be helpful. Thanks in advance.
Clement
0 Kudos
Message 1 of 7
(4,395 Views)
How are you retreiving the data from the SQL database in LabVIEW??  Are you using the LabSQL vi's (if so, which ones) or did you make your own SQL command vi's??

Here is some nice information on  sql, if you are looking to learn somemore :http://www.w3schools.com/sql/sql_intro.asp

My guess is that the date format is specified somewhere (by LabSQL or your vi's) and it is reading the date as it is in the datbase, but it gets converted to the format you are seeing before it is outputted from the vi.  So where that conversion is taking place needs to be determined.

How are you displaying the data from the query??  In a table, array, single string or numeric??  You might want to check the formatting of the indicator in LabVIEW to see how the date is displayed.
Kenny

0 Kudos
Message 2 of 7
(4,367 Views)
Hi Kenny K. thanks
All data in the database is saved in the year 2007 and will be saved on onbwards so I dun think the year issue  is a big issue.
 
Yes I am using LabSQL and I have already learned these in the website U mentioned.
 
Ok it is working. All I have to do is to convert the format so that it can be read correctly.
 
However,  it acts strange.  In the database,  the date is formated as 0000-00-00 00:00:00 and the type is datetime as I created.
 
In WinXP, the simple labview progran reads as 12/18/2007 2:45:24 PM while in win2K it reads, 18-Dec-06 14-51-25.
How can I resolve these problems? Looks I have to make 2 programs for each platform?
 
Pls advise
Clement     
0 Kudos
Message 3 of 7
(4,336 Views)
The only thing that I can think of that explains a difference between an XP machine and a Win2000 machine would be the Regional, Date/Time settings in the control panel are different between the two machines.  If the labview VI is using system format settings, it would get them from the control panel and maybe they are different.
0 Kudos
Message 4 of 7
(4,334 Views)
Hi Ravens. It works. Thanks

Clement
0 Kudos
Message 5 of 7
(4,325 Views)
Hi Ravens. I think that not all computers have the same settings. Is there a way how can make sure that it still works despite of different settings in esch PC?
By auto-changing registry?

 Clement
0 Kudos
Message 6 of 7
(4,322 Views)


astroboy wrote:
Hi Ravens. I think that not all computers have the same settings. Is there a way how can make sure that it still works despite of different settings in esch PC?
By auto-changing registry?

 Clement



There probably is a way to do that, but I don't know how.  I don't think it is a good idea to change the PC settings in that way because it would interfere with all other programs on the PC.  Suppose the user wants the format of date and time to remain the way it is for other programs or looking at file/directory properties.

Rather than basing your functions on the system format settings, use the format string functions within labview that will make the date/time to appear the way you want it to.  Look at the format date/time string function on the timing palette.  Also, format into string on the string palette.

0 Kudos
Message 7 of 7
(4,303 Views)