formating a date

liunx

Guest
hello all,

currently i have an asp page using VB and there is a field that i need to format into 24 hour time, and insert into the database.

At the moment I have a functions.inc file with the function called UpdateTime in it.

the function is shown below

The problem is that when the page get loaded it reads the database for details. Then fills in the text boxes with database data. The field that i am having trouble formatting is on the update part of the page, i.e. the user has clicked on an existing item and needs to update data about it. I want the user to be able to enter in any kind of data and my code will format it appropriatly and then insert it into the database. The data type in the database is "datetime".

here is the function:


Function UpdateTime(time)
length = Len(time)
time = Trim(time)
if InStr(time, ":") = 0 and IsNumeric(time) then
tempR = Right(time,2)
tempL = Left(time,(length - 2))
time = tempL & ":" & tempR
end if
time = "1/01/1900 " & time
UpdateTime = date
End Function


where 'time' is the data in the text field.

I think the main problem is that im not really getting tyhe whole datetime formatting issue, im treating the time variable as though it is a string, is this correct?

Sorry if i suck at explaining things...ummm...that code i posted does actually seem to work for now. I dont know why i thought it didnt.

BTW, the reason i put 1/01/1900 in the string is because im not really concerned with the date, just time
 
Back
Top