Micro Focus QTP (UFT) Forums
How to get custom formatted date from qtp - 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: How to get custom formatted date from qtp (/Thread-How-to-get-custom-formatted-date-from-qtp)



How to get custom formatted date from qtp - sailakshmi - 08-23-2008

Hi,

I am trying to get a date format changed from YYYY-MM-DD to mm/dd/yyyy.

can someone please help to set this date format?

Thanks,
Sai


RE: How to get custom formatted date from qtp - QADBA - 08-25-2008

If your date format is an string (from an inputfield or sth like that), you can dismember the string in different parts:

Code:
year = left(YYYY-MM-DD, 4)
month = left(right(YYYY-MM-DD, 5), 2)
day = right(YYYY-MM-DD, 2)

newdateformat = month & "/" & day  & "/" & year

You have to adapt the code if you have no leading "0", 23.5.2008 instead of 23.05.2008.

Hope this helps.


RE: How to get custom formatted date from qtp - nilanjans - 07-19-2012

Hi,

Below code might help to fulfill the requirement.Just Used 2 VBScripts functions to meet the requirement.

Code:
x="2012-07-19"
msgbox x

z=Replace(x,"-","/")
msgbox z

z1=Split(z,"/")

msgbox z1(1)+"/"+z1(2)+"/"+z1(0)


If anyone having better idea please share like ( FormatdateTime functions will work or not i am not sure)

Thanks,
Nilanjan


RE: How to get custom formatted date from qtp - K Gaurav Varshney - 07-20-2012

Code:
GetDay = DatePart("d", TheDate)
   GetMonth = DatePart("m", TheDate)
   GetYear = DatePart("yyyy", TheDate)
   MyDate = month & "/" & day & "/" & year

try this...it will also help you.


RE: How to get custom formatted date from qtp - ravi.gajul - 07-20-2012

You can also try
Code:
MsgBox FormatDateTime(#2012-07-20#,vbShortDate)
'vbShortDate-Displays a date using the short date format specified in your computer's regional settings.

Regards,
Ravi