| Author |
Topic Search Topic Options
|
pedalcars
Senior Member
Joined: 12 August 2002
Location: United Kingdom
Status: Offline
Points: 268
|
Post Options
Thanks(0)
Quote Reply
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
|
|
|
 |
Gullanian
Senior Member
Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
|
Post Options
Thanks(0)
Quote Reply
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).
|
 |
pedalcars
Senior Member
Joined: 12 August 2002
Location: United Kingdom
Status: Offline
Points: 268
|
Post Options
Thanks(0)
Quote Reply
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.
|
|
|
 |
Gullanian
Senior Member
Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
|
Post Options
Thanks(0)
Quote Reply
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)
|
|
 |
Gullanian
Senior Member
Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
|
Post Options
Thanks(0)
Quote Reply
Posted: 09 October 2003 at 5:01pm |
Just looking actualy, I think there is a built in function, try:
|
 |
pedalcars
Senior Member
Joined: 12 August 2002
Location: United Kingdom
Status: Offline
Points: 268
|
Post Options
Thanks(0)
Quote Reply
Posted: 09 October 2003 at 6:45pm |
Gullanian wrote:
Just looking actualy, I think there is a built in function, try:
|
Generates:
01/01/1900
For me!
Thanks for looking though; I'm currently using DateDiffwhich is so far giving me a perfectly useable solution.
|
|
|
 |