Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Convert string to datetime in classic asp

Posted on 2015-01-23
1
Medium Priority
?
1,632 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 34

Accepted Solution

by:
Big Monty earned 2000 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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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 lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Screencast - Getting to Know the Pipeline
Suggested Courses

972 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