DateFormat help - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners) +--- Thread: DateFormat help (/Thread-DateFormat-help) |
DateFormat help - AutomationTester2011 - 05-31-2011 I need the script for displaying date format exactly as below.. eg: if date is may 31 2011 then it has to display as - "2011-05-31" For example if the date is "01/02/2012" then it should display as "2012-02-01" and it should not display as "2012-2-1" Please help RE: DateFormat help - manabh - 05-31-2011 Hi Use format(dtDate, "yyyy-MM-dd") function. Just check if the function is Format or FormatDate only. RE: DateFormat help - AutomationTester2011 - 05-31-2011 Verified but its throwing error currDate1 = FormatDateTime(dtDate, "yyyy-mm-dd") PRINT currDate1 Type mismatch: '[string: "yyyy-mm-dd"]' "currDate1 = FormatDateTime(dtDate, "yyyy-mm-dd")". RE: DateFormat help - vIns - 05-31-2011 Hi... You can get Date in D, M, YYYY format using DatePart method. In order to display 5 as '05', You need to comeup with ur own function. As far as i know, there is no such method in VBScript. RE: DateFormat help - sreekanth chilam - 05-31-2011 Hi, You can try with the below ways: Way1: Use FormatDateTime built-in function ( Refer the QTP help file for more info.) Way2: Refer the below code Code: x="May 31 2011" RE: DateFormat help - vIns - 05-31-2011 You can use this... Code: Function FormatYYYYMMDD(timeStamp) RE: DateFormat help - AutomationTester2011 - 05-31-2011 Vins and chalam Sorry guys..just b4 i saw ur replies...i also got solution as below..thanks a lot Code: currDate = FormatDateTime(Date, 2) |