LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default vba date function

Hi,
I don't really know what is wrong with this function, might be
something very basic.
I had a vba function that reads date in form 19501220 and spits out a
date serial 18617, which could be reformat in excel like 12/20/1950

The vba function is:

Public Function SDate(strDt As Long)
If strDt <19000101 Then SDate = 0: Exit Function
SDate = DateSerial(Left(strDt, 4), Mid(strDt, 5, 2), Right(strDt, 2))
End Function

The problem is from date 19000101 to 19000229 the function produces one
day in advance, e.g.
19000101 (1st day) will be 1/2/1900
19000229 (day 61th) will be 3/1/1900
From 19000301 upto present date the function gives correct date.


Thanks for all clarifications.
Dailoc

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function to lookup date on tab in excel and populate date on calen MGC Excel Worksheet Functions 0 February 4th 10 04:48 AM
Difference betwen Excel Date () Function and System Date Khalil[_2_] Excel Worksheet Functions 2 June 16th 09 01:10 PM
SUMIF within date range as a function of today()'s date irvine79 Excel Worksheet Functions 8 August 6th 06 05:55 PM
Date Function formula that will return the date of a specific week Greg Excel Worksheet Functions 4 June 12th 06 05:07 PM
Calculating days between current date and a date in future NETWORKDAYS() function Faheem Khan Excel Worksheet Functions 2 February 10th 05 07:18 PM


All times are GMT +1. The time now is 07:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"