Solved

Convert string to datetime in classic asp

Posted on 2015-01-23
1
1,161 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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
format nvarchar field as mm/dd/yyyy 4 78
VBSCRIPT string remove all characters to the right after extension 4 67
innerHTML 7 34
Asp in script 6 37
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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