Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 9th, 2008, 09:48 AM
Authorized User
 
Join Date: Dec 2005
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Date to number- Please Help!

This is kind of crazy but here goes. I need to first take a timestamp, then break it into two variables: date and time. But when I write it to my database, I want to write both variables as numbers with no formatting.

For example: 06/06/2008 1:23 PM
   would become:
                     060608 and 1323

Please help. If it can be done, I know someone here knows how....you guys are my heroes!
 
Old June 9th, 2008, 01:10 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Trivial:
Code:
dt = ...some date and time variable or value ...

dayNumber = Month(dt) * 10000 + Day(dt) * 100 + (Year(dt) MOD 100)
timeNumber = Hour(dt) * 100 + Minute(dt)
But I would like to comment that your "dayNumber" is now a value that you can *NOT* compare!

That is, you can't do
    If dayNumber1 > dayNumber2 Then
and have it do anything meaningful.

You'd be a lot better off using the format YYYYMMDD if you want to be able to compare the resultant numbers in any meaningful way.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation For Phone Number and Mobile Number dhruthi.ram99 Javascript How-To 12 October 30th, 2011 07:24 AM
How to calculate a number of days between 2 date windy417 Pro JSP 1 July 20th, 2006 07:09 PM
Convert date to number samirz10 Access 1 July 22nd, 2005 03:04 PM
Week number to a date pdistant ASP.NET 1.0 and 1.1 Professional 5 August 17th, 2004 07:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.