Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8679097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:53:10+00:00 2026-06-12T20:53:10+00:00

I want to read date time from ms access database . the column is

  • 0

I want to read date time from ms access database .

the column is of datatype DATETIME and value is : 1/27/12 5:10 PM

<html>
<body>
<%



Dim Conn
Dim Rs
Dim sql

Dim sConnection


Dim Today as Date //this gives error - unexpected end of file , i want to display current date and time ??? 


Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")

 filepath= Server.MapPath ("mydb.mdb") 
sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="  & filepath

Conn.Open(sConnection)



sql="select * from items;"

Set Rs = Conn.Execute(sql)

if Rs.EOF then

    Response.write("No records found")
else 


    do until rs.eof


            ctime =     rs("itemadditiondatetime")

            Response.write("<br/>Time : <input name='dateandtime[]' value=" & ctime & "/>" & ctime )


            rs.movenext

    loop

end if

Rs.Close
Conn.Close

Set Rs = Nothing
Set Conn = Nothing


%>
</body>
</html>

In all text boxes only date is displayed ( 1/27/12 ) , time is not being displayed , but when I display without text box then whole datetime is displayed. also how do i get date and time separately in two text boxes.

Also , I need to format date as yyyy-mm-dd.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:53:11+00:00Added an answer on June 12, 2026 at 8:53 pm

    If this is classic ASP/VBScript:

    'Dim Today as Date 
    Dim Today ' without declaring data type
    

    You can use the FormatDateTime function to get the date and/or time component from your ctime value.

    FormatDateTime(ctime, 3) ' long time
    FormatDateTime(ctime, 2) ' short date
    

    See the linked page for other FormatDateTime options in case you prefer different formats than I suggested.

    I overlooked “need to format date as yyyy-mm-dd“. Unfortunately, VBScript doesn't provide VBA's Format(ctime, "yyyy-mm-dd") feature. So I think you may have to extract the year, month, and day pieces from ctime, and them recombine them in the order you want.

    Year(ctime) & "-" & Right("0" & Month(ctime), 2) & _
        "-" & Right("0" & Day(ctime), 2)
    

    I realized you could simplify your ASP code by asking the db engine to give you the date and time pieces formatted as you wish. Although VBScript can’t use the Format() function, the db engine can.

    SELECT
        Format(itemadditiondatetime, "hh:nn:ss") AS time_string,
        Format(itemadditiondatetime, "yyyy-mm-dd") AS date_string
    FROM items;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading data from remote oracle database with read only access . and
I want to read a INI file from python, and I came up with
i want to read an html file by using jquery get function, replace some
I want to read the pdf file from raw folder if devices have any
I want to read .ppt files from the iPhone mail app. I have already
I want to read and save some data from this rss feed to in
I read berfore SQL Count for a Date Column and SQL to get count
So I'm kinda new to the Calendar/Time/Date stuff in Java but I've read a
Hi I can't understand this error I want read this XML file: <?xml version=1.0
I have a text file. I want read that file. But In that if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.