Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import into SQL Table from Txt

Status
Not open for further replies.

topci

Programmer
May 6, 2005
16
SI
Hi,
I have a little stupid problem. I need transfer data from txt file (using visual basic application) direct to SQL table. The Date field in TXT table is in yymmdd format (for example: 051103). When I write into SQL data over ADO and convert date field into next format: '11/03/2005', I get in Sql table format 11-03-2005 (month: 03, day: 11, year: 2005). And this is wrong. With same logic (and same version) is the date format for 051129 correct.

Any ideas, what can be wrong?

DaT
 
Seeing the code you're using could perhaps give us something to work with - else we're just guessing ... now then, one guess, based on what seems to be a fascination of dynamic SQL, is that you concatenate a UK date into a string, which you then later feed to the database. Try feeding either US date or Ansi... say

[tt]dim mydate as date
dim strdate as string
dim strsql as string
strdate="051103"
mydate = dateserial(clng(mid$(strdate, 1,2)), clng(mid$(strdate(3,2)), clng(mid$(strdate(5,2)))
strsql = "<myexising sql> , '" & format$(mydate, "yyyy-mm-dd") & "', ...[/tt]

I e - feed the string with an unambiguous date format, or check out chiph's faq faq709-1526 for another (better) way of passing parameters ...

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top