Date Format change - 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: Date Format change (/Thread-Date-Format-change) |
Date Format change - mv8167 - 02-28-2012 I am trying to change the DateRequested from 2/27/2012 to 02-27-2012 my code is as such: Code: DateRequested = FormatDateTime(Date, 2) i am getting a Run Error: Overflow What must i change? My date is returned as "02/27/2012" (I found this code on the web and updated it with my values.) RE: Date Format change - inborntester - 02-28-2012 Right function first argument should be string type. Can you try like. Code: stryear = Right("02/27/2012", 4) moreover you can try the simply way by using month,day,year functions. Code: DateRequested="02/27/2012" RE: Date Format change - mv8167 - 02-28-2012 Thx again Inborntester With: DateRequested="02/27/2012" #1, Using: Code: DateRequested = month(DateRequested) & "-" & day(DateRequested) & "-" & year(DateRequested) stryear = right(DateRequested, 4) Code: strmonth = left(DateRequested, 2) "02-28-2012" Can #1 also show as "02-28-2012"? RE: Date Format change - inborntester - 02-29-2012 Can #1 also show as "02-28-2012"? - think can not at direct, but from workaround we can. better go ahead #2 if you need 0. RE: Date Format change - sshukla12 - 03-02-2012 Hi, U can use Dot net factory..it will make ur life easier. Regards, Sankalp RE: Date Format change - mv8167 - 03-02-2012 Thx sshukla12 Great idea. Ok, now what is Dot Net Factory. lol I'll look it up. cheers L RE: Date Format change - sshukla12 - 03-05-2012 Hi, Like the interface u have in .net ,.net factory will provide u the same interface and u can use this to retive the date in the desired format. Go to QTP help u will find all the details. In any confusion let me know. Regards, Sankalp RE: Date Format change - Saajo87 - 03-05-2012 Hi Lorena, Try this.......... Code: Dim sDate,sArr Output : 02-27-2012 ~~Cheers, Sachin. RE: Date Format change - mv8167 - 03-05-2012 Saajo87, Thx, this works awsome! thx Lor RE: Date Format change - SteveS - 03-05-2012 You could just use Replace: NewDate = Replace(date,"/","-") |