ASP Format Date

Posted on 2009-04-23
Last Modified: 2012-06-27
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

Question by:wellsuited
    LVL 5

    Expert Comment

    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)
      document.write("Not a date/time!")
    end if
    if IsDate(restime) then
      restime= CDate(restime)
      document.write("Not a date/time!")
    end if
    'Now you can insert into your database

    Open in new window

    LVL 48

    Accepted Solution

    >>How do I convert so that they will insert in date time format.

    just make sure your date value is in proper date format, so try format your date value into format of : mm/dd/yyyy  if you got an original date value in dd/mm/yyyy.

    you no need to use CDate in this case.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
    This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now