Hi,
I writing the following code :
Dim tmpdate As NotesDateTime
Set tmpdate = New NotesDateTime(doc.sebap_date(0))
mySAPDate$ = Format$(tmpdate.DateOnly, “YYYYMMDD”)
Now I want to convert mySAPDate$ to datetime using CDat or anyother methods. I tried it, but it throws an error, “Type Mismatch”.
Pls help.
Subject: Cannot convert to Date
It must be your source date (doc.sebap_date(0)), because when I replace this with Now() all goes well.
Subject: Cannot convert to Date
I want to double check, do you want to convert mySAPDate$ to a datetime or NotesDateTime? These are not the same.
mySAPDate$ is a string.
CDat wants a numeric or string. Reading the help, if the string can be converted to a numeric, it will and then try and turn that number into a date.
An alternative would be to use datenumber:
datenumber ( Left(mySAPDate$,4), Mid(mySAPDate$,5,2), Right(mySAPDate$,2) )
Subject: RE: Cannot convert to Date
Hi,
Thanks. But after using DateNumber, the date does not remain in YYYYMMDD format, it gets converted to mm/dd/yyyy format. I want to keep the date in YYYYMMDD format.
Pls help.
Subject: RE: Cannot convert to Date
Dates do not have formats, they are just numbers. If you want to display the date as a string with a given format, you have a number of options (using a custom format on a date/time field, using Format in LS and writing a string somewhere, etc.). Cdat and Cstr use the regional settings of the machine they are running on.
Subject: RE: Cannot convert to Date
As always, if you are having an error, your code sample should include the line that gives the error.
Type mismatch occurs when you use a variable which is of the wrong type. It has nothing to do with the value of the variable, only its type.
For instance, if you use an array where a string is expected. There’s no way to automatically convert an array to a string, so you get this error.
- Andre Guirard, IBM/Lotus Development
Useful blog: Best Practice Makes Perfect
For faster answers, be C R I S P Y