I h开发者_Go百科ave a program that gets input in the form of an excel which it reads by querying (select * into a dataset).
The excel is created by the customer. The excel contains a date column. The problem is, that when looking into the dataset, the date column format is sometimes like mm/dd/yyyy and sometimes dd/mm/yyyy. (1/25/1970) (25/1/1970)I guess it depends on the locale on the machine which the excel was made.
How can my program know what is the date format in the excel?
Not sure whether your question is about output or input...
For output:
You did not mention the database type. But the rule is: make your dates the american way: mm/dd/yyyy. For Jet, I generally use Format(MyDate, ""\#dd\/mm\/yyyy\#"")
("\" is the escape character, it makes sure the next character is output "as is")
For input:
Try reading the cell format ? range("a1").NumberFormat
However on my PC, with French setup a date displayed as 15/2/2011 has a returned format = m/d/yyyy
so little use here !
精彩评论