![]() |
Incorrect Date Returned
Hi
I have a cell which is in text format. The cell is referenced as a string. I then need to check to see if the entered date/number entered into the cell is before todays date. I use the following code to change the format of the cell number/date to become an actual date however the wrong date is shown. rngFromC = 281006 stFromaDateNameC = rngFromC If stFromDateNameC <= 999999 Then stFromDateNameC = Format(stFromDateNameC, "mm/dd/yy") stFromDateNameC = DateValue(stFromDateNameC) End If when converted into date format it shows 13/05/1969 I dont understand why it doesn't show as 28/10/06. Any idea's Thanks Noemi |
Incorrect Date Returned
You should use Option Explicit, you have different variable names in that
code, stFromDateNameC and stFromaDateNameC. Try this instead rngFromC = DateSerial(28, 10, 6) stFromDateNameC = rngFromC If stFromDateNameC <= 999999 Then stFromDateNameC = Format(stFromDateNameC, "mm/dd/yy") End If -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Noemi" wrote in message ... Hi I have a cell which is in text format. The cell is referenced as a string. I then need to check to see if the entered date/number entered into the cell is before todays date. I use the following code to change the format of the cell number/date to become an actual date however the wrong date is shown. rngFromC = 281006 stFromaDateNameC = rngFromC If stFromDateNameC <= 999999 Then stFromDateNameC = Format(stFromDateNameC, "mm/dd/yy") stFromDateNameC = DateValue(stFromDateNameC) End If when converted into date format it shows 13/05/1969 I dont understand why it doesn't show as 28/10/06. Any idea's Thanks Noemi |
All times are GMT +1. The time now is 02:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com