Link to home
Start Free TrialLog in
Avatar of wellsuited
wellsuited

asked on

ASP Format Date

I have two strings that need to be converted before inserted into an access database. The fields that they are to be inserted are date/time.
How do I convert so that they will insert in date time format.
resdate = "somedate"
restime = "sometime"
 
insert into table (flddate, fldtime) values (resdate, restime)

Open in new window

Avatar of synx
synx
Flag of United States of America image

You can use CDate() to convert the values to Date/Time before inserting them.  An example could be:
if IsDate(resdate) then
  resdate = CDate(resdate)
else
  document.write("Not a date/time!")
end if
 
if IsDate(restime) then
  restime= CDate(restime)
else
  document.write("Not a date/time!")
end if
 
'Now you can insert into your database

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial