-
October 22nd, 2002, 10:40 AM
#1
System time format (Answer found)
Hi,
do you know how I can get the system time format from Windows?
My problem is that I have the date as a string, under a format I know about. I want to create a csv file to be able to open it in Excel. Excel use the system format to look if a string is a date or not.
The problem will mainly appear for month/day. Usually, english format will be: "10/22/2002" while some other formats will be "22/10/2002".
I need to know how to format the string in order to have excel recognise the string as a date, and not as a simple string. This is a window setting as you can change it in the control panel, so there must be some API function to look for it, but I don't know which...
Any idea?
Last edited by Elrond; October 22nd, 2002 at 10:55 AM.
Elrond
A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise.
-- George Steiner
-
October 22nd, 2002, 10:47 AM
#2
take a look at setlocale()
may be could help you.
-
October 22nd, 2002, 10:54 AM
#3
Answer found
Thanks.
What I was looking for is the format item %c.
Elrond
A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise.
-- George Steiner
-
October 22nd, 2002, 12:41 PM
#4
If the data is for a cell then it is possible to set the cell format. That way Excel is much more likely to process the data as a date.
-
October 22nd, 2002, 02:25 PM
#5
...This is a window setting as you can change it in the control panel, so there must be some API function to look for it, but I don't know which...
The Windows SDK function to query locale settings is GetLocaleInfo.
-
October 23rd, 2002, 01:50 AM
#6
Originally posted by Sam Hobbs
If the data is for a cell then it is possible to set the cell format. That way Excel is much more likely to process the data as a date.
That's to write in a CSV format file, so it's not possible to set a cell format. On the other hand, even if you set the cell format as a date, if the string does not have the date and day in the correct position, at best it is just recognised as a string (if the day is more than 12), or even worse, it will invert month and day!!!!
So I think the best is to use the proper format for the string in the first place.
Elrond
A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise.
-- George Steiner
-
October 23rd, 2002, 01:51 AM
#7
Originally posted by alpha137
The Windows SDK function to query locale settings is GetLocaleInfo.
Thanks.
As I'm just interested in the date/time format the %c format item does it much more easily (and probably quickly) for me.
Elrond
A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise.
-- George Steiner
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|