0

I have a string in yyyymmdd format and need to pass that to a function which date type. I have also listed the definition of GetCP function

Dim sp As String() = fName.Split(".")
Dim  fdate As string = sp.Substring(0,8)
Dim dt As String  = fDate
Library.GetCP(dt)  '' getting an error here as the not the right format.
Friend Shared Function GetCP(ByVal TDate As Date) As String
Igor
  • 60,821
  • 10
  • 100
  • 175
user565992
  • 497
  • 2
  • 10
  • 17
  • 1
    Try converting your `String` to a `Date` before passing it. [Here is a post](https://stackoverflow.com/q/919244/5162073) showing how to do that. – Brian M Stafford Aug 09 '19 at 14:44
  • 1
    It's not that its the wrong format but it's the wrong type. A `System.String` is not a `System.DateTime`. If your input is `string` then you must convert it to a `System.DateTime` and pass that to your method call as that is the expected input type. – Igor Aug 09 '19 at 14:49

0 Answers0