Incorrect Date Returned

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top