Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Convert date to serial number
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Convert date to serial number

 Post Reply Post Reply
Author
pedalcars View Drop Down
Senior Member
Senior Member


Joined: 12 August 2002
Location: United Kingdom
Status: Offline
Points: 268
Post Options Post Options   Thanks (0) Thanks(0)   Quote pedalcars Quote  Post ReplyReply Direct Link To This Post Topic: Convert date to serial number
    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
www.pedalcars.info

The most fun on four wheels

Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post 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).
Back to Top
pedalcars View Drop Down
Senior Member
Senior Member


Joined: 12 August 2002
Location: United Kingdom
Status: Offline
Points: 268
Post Options Post Options   Thanks (0) Thanks(0)   Quote pedalcars Quote  Post ReplyReply Direct Link To This Post 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.
www.pedalcars.info

The most fun on four wheels

Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post 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)

Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 09 October 2003 at 5:01pm

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


DateSerial(1900,1,1)

Back to Top
pedalcars View Drop Down
Senior Member
Senior Member


Joined: 12 August 2002
Location: United Kingdom
Status: Offline
Points: 268
Post Options Post Options   Thanks (0) Thanks(0)   Quote pedalcars Quote  Post ReplyReply Direct Link To This Post 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.

www.pedalcars.info

The most fun on four wheels

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.