I want to be able to format my time as 7:00 PM in an ASP page. If I don't format it at all it will show up at 7:00:00 PM. If I use a FormatDateTime function with vbShortTime I get it in military time (19:00). Is there a way to format it as 7:00 PM using ASP?
Try using the left/right function to cut out the last two zeros:
dim strTime
strTime=rs("MyField"
if len(strTime)=11 then
strTime=left(strTime,4) & " " & right(strTime,2)
else
strTime=left(strTime,5) & " " & right(strTime,2)
end if
Thread
RushiShroff (Programmer) Feb 1, 2002
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
Inappropriate post?
If so, Red Flag it!
Check out the FAQ
area for this forum!
Ovatvvon (Programmer) Feb 1, 2002
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
Click here to mark this post as a helpful or expert post!
Inappropriate post?
If so, Red Flag it!
Check out the FAQ
area for this forum!
RushiShroff (Programmer) Feb 1, 2002
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
Inappropriate post?
If so, Red Flag it!
Check out the FAQ
area for this forum!
Ovatvvon (Programmer) Feb 2, 2002
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,
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.