Hi guys

When I ask VB to display a date obtained from a field in Access I get a date that displays the day ok, the year okay but it displays the month as 00. In other words 20100029. Now, I have to evaluate the date difference between todays' date and this date obtained from Access and of course I receive an error message.

Can anyone please tell me how to configure things from Access so that the correct date is displayed?



7 Years
Discussion Span
Last Post by AndreRet

what code did u use when accessing that field?
if i understand correctly that date was already stored in your access database right?
did u try to open ur ms access file and see what date stored there?


It seems that the date was saved incorrectly to your Access database in the first place. You need to check the way the data gets saved in Access. To ensure that it is correct, use a syntax like -

YourDateTextBox.Text = Format(Date, "dd/mm/yyyy")

When you retrieve the date you will have something like -

YourDateTextBox.Text = rsDate!MyRetrievedDate

By using the 'Format Function' you eliminate all possible errors when saving the data.

To calculate the difference between two dates, I have used the following, which is only a suggestion. I do realise that you did not question anything on obtaining a date difference -

YourDateDiff.Text = DateDiff("d", YourStartDate.Text, YourEndDate.Text)
'd = days, m = months etc

I hope this solves your problem.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.