Assign date in VB Script (DTS)

  • I need to assign a date to a field in DTS

    Dim MyDate,MyShortDate

    MyDate = "February 12, 1969"   ' Define date.

    MyShortDate = CDate(MyDate)

    DTSDestination("cmng_update_date") =MyShortDate

    But I get an error that " Type mismatch :'CDate'"

    What's wrong?

  • Try this

    Dim MyDate, MyShortDate

    MyDate = "1969-10-19"   ' Define date.

    MyShortDate = CDate(MyDate)

    MsgBox MyDate

    MsgBox MyShortDate

    Don't ask why this works and the other doesn't....

     



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • Plese, verify the data format before convert.

    You can explicit the format for data in convert clause.

     

     

     

     


    Hildevan O Bezerra

  • The error message means that CDate can't convert the argument to a date.  Since your argument looks like a date to me, is it possible that your locale is set to something that doesn't recognize that string or format?  The locale will affect the way that dates are converted, and "February" is not a month in all locales.  GetLocale will tell you what CDate is expecting.

  • thank you very much for all answers. It really helped me.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply