Print Page | Close Window

Convert date to serial number

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=6292
Printed Date: 31 March 2026 at 1:17pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Convert date to serial number
Posted By: pedalcars
Subject: Convert date to serial number
Date Posted: 09 October 2003 at 2:21pm
I want to convert dates to serial numbers, in the same way Excel does, so for example instead of having 9/10/2003, I'd get 37903.

Is this possible in ASP? As simply as possible...

Ta


-------------
http://www.pedalcars.info/ - www.pedalcars.info

The most fun on four wheels




Replies:
Posted By: Gullanian
Date Posted: 09 October 2003 at 3:37pm
If you tell me what the serial number stands for I might be able to write you a function (unless there is a built in one im unaware of).


Posted By: pedalcars
Date Posted: 09 October 2003 at 4:10pm
As I understand it, in Excel the number is the number of days since 1/1/1900, apart from the problem that MS thought 1900 was a leap year, or something...

I could pick an arbitrary date of my choosing and use datediff, nice and simple; I have also searched and found some functions that do this. However, I was wondering (like Gullanian is) if there is a built-in function to do it.

-------------
http://www.pedalcars.info/ - www.pedalcars.info

The most fun on four wheels



Posted By: Gullanian
Date Posted: 09 October 2003 at 4:59pm

Ah ok thats no problem, simply do datediff.

So:


  Dim datTodaysDate
  Dim datExcelStartDate
  Dim lngOutput

  datTodaysDate = now()
  datExcelStartDate = cDate("1/1/1900")

  lngOutput = Datediff(d,datTodaysDate,datExcelStartDate)



Posted By: Gullanian
Date Posted: 09 October 2003 at 5:01pm

Just looking actualy, I think there is a built in function, try:


DateSerial(1900,1,1)



Posted By: pedalcars
Date Posted: 09 October 2003 at 6:45pm
Originally posted by Gullanian Gullanian wrote:

Just looking actualy, I think there is a built in function, try:


DateSerial(1900,1,1)



Generates:

01/01/1900

For me!

Thanks for looking though; I'm currently using DateDiffwhich is so far giving me a perfectly useable solution.



-------------
http://www.pedalcars.info/ - www.pedalcars.info

The most fun on four wheels




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net