This question already has an answer here:
My issue is when I retrieve date back it gives me in this format:
lastseenstatus=rsprefobj("lastseentstamp")
19-07-2014 15:31:32
I want it in 7/19/2014 3:31:32 PM
format with AM/PM
intact.
Please help..
First and foremost you need to determine the data type of
rsprefobj("lastseentstamp")
:If it's a string, you need to convert it to a datetime value first:
If you want the date formatted according to the system's regional settings, use the
FormatDateTime()
function as @John suggested:If you need a distinct date format regardless of the system's regional settings you have to either build the formatted string yourself:
or use the .Net
StringBuilder
class:In my tests I wasn't able to get the
tt
format specifier to work, though, so you may have to resort to something like this:I'm assuming you are using VBScript and not VB.NET like you have tagged.
Use
FormatDateTime(lastseenstatus)
.That should give you the format "2/16/2010 1:45:00 PM".