Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP and Access DateTime

Status
Not open for further replies.

RushiShroff

Programmer
Jan 23, 2002
216
IN
I have a table in access 2000 DB in which there is a field
"Account_Created_Date".I have given datatype "DateTime"

Now I want to insert Time along with Date while account is created.How can I do it with SQL/ASP script?

Regards
X-)
 
same things as any other data you are entering into the database. Just assign the server date/time value to a variable to be inserted with the rest of your data...

Dim AccountStart
AccountStart = now()
'will assign the date and time as of Right Now!


Hope this helps! -Ovatvvon :-Q
 
NoW I have inserted DateTime using Now() in the ACCess DB.
How can I seperate them ?
That is while retriving how can I seperate time fraction ?

Regards
 
To format your date input from the database, on your output use the formatDateTime() function. You can pull and display your db value in one of several ways:

------------------------------------------------


formatDateTime(now(),0) = 2/2/2002 1:36:55 AM

This shows just as it is in the db.


formatDateTime(now(),1) = Saturday, February 02, 2002

Long Date


formatDateTime(now(),2) = 2/2/2002

Short Date


-------------------------------------------


formatDateTime(now(),3) = 1:38:41 AM

12 Hour Clock


formatDateTime(now(),4) = 01:35

24 Hour Clock


-------------------------------------------


Additionally, you can pull direct fields from the value using Month(), Day(), Year(). If you were to write,

Response.write Month(now()) & "/" & Day(now()) & "/" & Year(now())

the output would be 2/2/2002

or you can pull time elements like so,

Response.write Hour(now()) & " " & Minute(now()) & " " & Second(now())

Which will produce 1 50 15


You can get more reference to these functions at:




Hope this helps! -Ovatvvon :-Q
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top