Forum Discussion

SamuraiJack's avatar
SamuraiJack
Contributor
14 years ago

Best way to convert date mm/dd/yyyy from table data to yyyy-mm-dd in VBScript?

Trying to reconcile the display of data in a web table to the same data from a DB2 DB.  Unfortunately my company has no formatting continuity.



Table dates are in the mm/dd/yyyy format, and of course DB is in yyyy-mm-dd.



I've tried this to try and get the data format to be recognized as a date so I can use CDate:



dday = Tbl.rows(rd).cells(cd).outerText

dday = Chr(34)&"#"&dday&"#"&Chr(34)

if IsDate(dday) then Log.Message("This is a date")


But it doesn't appear to be working



Any suggestions on how to handle it?

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Have you tried utilizing aqConvert?



    procedure TestDataConvert;



    var

        MyDateString;

        MyDateDateTime;



    begin

    MyDateString := '04/01/2010';

    MyDateDateTime := aqConvert.StrToDateTime(MyDateString);

    MyDateString := aqConvert.DateTimeToFormatStr(MyDateDateTime, '%Y-%m-%d');

    Log.Message(MyDateSTring);



    end; 
  • To be honest, I hadn't even noticed that option when I was using it elsewhere LOL