截取时间问题
请看看下面的两种格式的时间2007-12-8 9:06:07 2007128964426513163
2007-12-8 11:00:59 2007128964426513163
这两种时间格式只有一个字符之差,怎么让上面两行数据都插入到access数据库中呢?
请各位高手帮帮忙!急用!
--------------------编程问答-------------------- 做两个列分别存放 --------------------编程问答-------------------- 什么意思啊?取日期和时间?是的话用split --------------------编程问答-------------------- 最好是存在一行,日期分别放在两个字段中 --------------------编程问答-------------------- 一个文件里同是存在上面的两种格式的时间,是用循环把它们存到数据库里的,请帮忙解决一下,谢谢! --------------------编程问答-------------------- i know what u mean:you wanna put them in database in the same format.
so you can revert them before put them into DB.
you can do as follow:
1. change the database field attribute(time/date 时间格式) to (string文本格式)
2. when you input the data,you can do
rs.fields("time")=format(a,"yyyy-MM-dd hh:mm:ss") (a:"2007-12-8 9:06:07"/"2007-12-8 11:00:59")
that's all.^_^ --------------------编程问答-------------------- maybe! --------------------编程问答--------------------
--------------------编程问答-------------------- 2007-12-8 9:06:07 2007128964426513163
'一次读出文本内容
Dim pFile As String
Dim hFile As Integer
Dim sFile As String
pFile = "C:\test.txt"
hFile = FreeFile()
Open pFile For Binary As hFile
sFile = Space(LOF(hFile))
Get hFile, , sFile
Close hFile
'提取数据:
dim arr() as string
dim arrFld() as string
dim i as integer
dim sql as string
arr=split(sFile,vbCrlf) '得到每行的行值
for i= 0 to ubound(arr) '一行行处理
arrFld=split(arr(i),chr(32)) '如果你每行数据是按空格拆分的话就这样
'插入数据库的SQL语句
sql="insert into tb(fld1,fld2,fld3) " _
&"values ('"& arrFld(0) &"','"& arrFld(1) &"','"& arrFld(2) &"')"
'cn.execute sql '插入数据库,这个你自己写
next
'思路就这样了
2007-12-8 11:00:59 2007128964426513163
不知道你这个是什么意思
补充:VB , 基础类