LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

format date to dd/mm/yy regardless of windows settings

Hi all,

When I get the date data from database, I noticed that the date format is depends on the system date format. For example, if I set the date format (from Windows Regional Settings) to dd/mm/yy, the date that I get from database will be as 31/12/05.. If I set it to dd/mm/yyyy, it will display as 31/12/2005.. May I know how can I code my program to get the date format permanently as dd/mm/yy regardless of what kind of date format that the Windows system may have?

THANKS!!
0 Kudos
Message 1 of 13
(4,643 Views)

What database are you getting the date from?

-Khalid

0 Kudos
Message 2 of 13
(4,630 Views)
Khalid

From Microsoft Access Database.... Any solution?
0 Kudos
Message 3 of 13
(4,625 Views)
Hi 222,

This is quite easy and well documented in the help topic...
If you use the "Format date/Time string" function,

to get 2005 => %Y
to get 05 => %y

see attached VI

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 4 of 13
(4,627 Views)
Hi Titou

Ya.. I know that method of formatting date but my date data from the database are in String format... how can I format it into Time Stamp? Any advise?
0 Kudos
Message 5 of 13
(4,624 Views)
Woops... sorry I missed the point on the first shot Smiley Sad

Well you said you are receiving a string that is either dd/mm/yy or dd/mm/yyyy depending on the computer settings, and waht you want it to always have dd/mm/yy, is that it ?

Then you can draw a function in a while loop that take the after string of a match pattern and link the "index found" to the stop and cut the yyyy to yy, like this :


Message Edité par TiTou le 02-22-2006 08:29 AM


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 6 of 13
(4,624 Views)
Thank you so much.. Will try it out!!!
0 Kudos
Message 7 of 13
(4,613 Views)
Hi Titou

Thanks for the example code.. But my date string is "31/12/2006 12:00:00 PM"... How can I get the time out and still will get 06 regardless of input of 2006 or 06...?
0 Kudos
Message 8 of 13
(4,611 Views)
What you may want to do to be safe is to modify the way in which the DB is outputting the date. For instance, if you're calling a built in query, you can right click the field in the design view and from the properties screen change the way it's formatted. The same thing can be done for tables. That way, no matter how the OS is set up, the DB will always return data in the same format.

___________________
Try to take over the world!
Message 9 of 13
(4,604 Views)
I have never used any DB in LabVIEW so I assume tst pointed the best solution.

If you still want to do it playing with the string, just add, before the string enters the loop, a  "match  pattern" the pattern being space and get the "before sub-string".

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 10 of 13
(4,594 Views)