Solved

Convert string to datetime in classic asp

Posted on 2015-01-23
1
1,211 Views
Last Modified: 2015-01-26
I need to be able to convert a piece of text to a datetime format. The text currently looks like this:

01/20/2015 1200

That is the date and time using military time.  I need to convert it to datetime so that I can some sorting and conditional statements.
0
Comment
Question by:princeservice
1 Comment
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 total points
ID: 40567305
You want to use the FormatDateTime function:

newDate = FormatDateTime( "1/20/2015 1200", 0 )

The 2nd parameter is for the format. They include:

0 = vbGeneralDate - Default. Returns date: mm/dd/yy and time if specified: hh:mm:ss PM/AM.
1 = vbLongDate - Returns date: weekday, monthname, year
2 = vbShortDate - Returns date: mm/dd/yy
3 = vbLongTime - Returns time: hh:mm:ss PM/AM
4 = vbShortTime - Return time: hh:mm

from http://www.w3schools.com/vbscript/func_formatdatetime.asp
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using querystring in a hyperlink 3 60
return false must be hit after calling certain command 10 43
ASP exit 10 26
Validating Date Part2 2 25
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

685 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