Author Topic: SQLDateTime 格式字串轉成 Double 的函數  (Read 4091 times)

admin

  • Administrator
  • *****
  • Posts: 0
    • View Profile
SQLDateTime 格式字串轉成 Double 的函數
« on: August 23, 2011, 07:37:08 PM »
Code: [Select]
Function SQLDateTimetoDbl(tmpDateTime as string) As double
  dim tmpResult as double
  dim tmpSQLDateTime as string
  dim tmpYear as string
  dim tmpMonth as string
  dim tmpDay as string
  dim tmpTime as string
  dim d as new date
 
  if len(tmpdatetime) =17 then
    tmpyear=left(str(d.year),2)+left(tmpdatetime,2)
    tmpmonth=mid(tmpDateTime,4,2)
    tmpday=mid(tmpdatetime,7,2)
    tmpTime=right(tmpdatetime,8)
   
    tmpSQLDateTime=tmpyear +"-"+tmpmonth +"-" +tmpday +" " + tmptime
    d.SQLDateTime=tmpsqldatetime
   
    tmpResult=datetodbl(d)
   
  else
    d=new date
    tmpresult=datetodbl(d)
  end if
 
  return tmpresult
     
End Function
« Last Edit: October 23, 2011, 01:47:42 AM by Roy Chan »