Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Format Question

Status
Not open for further replies.

llafretaw

MIS
Oct 2, 2001
64
GB
Hi,

In a nutshell I have a VB application that converts a string passed from a Sybase backend into a date value.
This string is a numeric value and is created in the first place by a Roguewave process (which represents a date and time, stored in milliseconds from Jan 1 1901 00:00:00:000).
My VB app always seems to convert to a date that is a year in the past. Is this because VB date def starts from Jan 01 1900? if so then I can just take the year diff into account..
Thanks
 
In vb day 1 is considered to be 31/12/1899. Therefore if your dates are calculated from 1/1/1901, then you need to add the amount from 31/12/1899 to 1/1/1901, as this is just over the year, and I think you'll find 1900 was a leap year.

Therefore, use the datediff statement:

myVBdate = mySybasedate + datediff("d", "31/12/1899", "1/1/1901")

This will add the correct number of days to the orignal date, and bring it to the correct value.

BB
 
and I think you'll find 1900 was a leap year this may be true in Excel but not with the date serial function or in the real world.

Leap years are years that are divisible by 4, except for years ending in 00 and are not divisible by 400. Well except if using MS Excel then 1900 was a leap year.

"Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top