Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get custom formatted date from qtp
#1
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
Reply
#2
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.
Reply
#3
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
Reply
#4
Code:
GetDay = DatePart("d", TheDate) GetMonth = DatePart("m", TheDate) GetYear = DatePart("yyyy", TheDate) MyDate = month & "/" & day & "/" & year

try this...it will also help you.
Reply
#5
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to append date to xls file using qtp datatable methods? yona34 1 2,215 05-04-2018, 08:56 PM
Last Post: Ankur
  QTP not recognizing date calendar kQTPs 1 4,043 12-20-2017, 11:21 PM
Last Post: harikrishna
  QTP11.0 - Date format is changed as text while executing the QTP script. Automation Tester 1 4,590 05-30-2014, 01:25 PM
Last Post: Tarik Sheth
  How to set value to custom property ? Ranu 0 2,369 11-14-2013, 02:58 AM
Last Post: Ranu
  Custom CheckPoint rajrkodeep 0 4,334 09-06-2012, 11:19 PM
Last Post: rajrkodeep

Forum Jump:


Users browsing this thread: 1 Guest(s)