Micro Focus QTP (UFT) Forums
Date Format needs adjustment - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Date Format needs adjustment (/Thread-Date-Format-needs-adjustment)



Date Format needs adjustment - unbeliever - 01-15-2010

Hello All,

My objective is to select date in the past, format it to dd.mm.yyyy format and input into field which validates only dates in this format. What I was able to produce so far is:

Code:
Dim TestDate
TestDate = DateAdd("d", -65, Date)

This code produces date in yyyy-mm-dd format. I have checked FormatDateTime function and there is no option to format date according to format that I require (dd.mm.yyyy). Since I have found no other VBScript functions which format dates I am asking whether you have encountered such situation and have some working solution?


RE: Date Format needs adjustment - unbeliever - 01-15-2010

Alert cancelled Smile , solution is as follows:

Code:
Dim TestDate, RUDDate
TestDate = DateAdd("d", -65, Date)

Date1 = Datepart("d",TestDate)
month1 = Datepart("m",TestDate)
year1 = Datepart("yyyy",TestDate)

If len(Date1) = 1 then
Date1 = "0" & Date1
Else
Date1 = Date1
End If

If len(month1) = 1 then
month1 = "0" & month1
Else
month1 = month1
End If

RUDDate = month1 & "." & Date1 & "." & year1



RE: Date Format needs adjustment - sreekanth chilam - 01-15-2010

Hi ,

Try in the below way Smile

Code:
Dim TestDate
  TestDate = DateAdd("d", -65, Date)
  dpart=datepart("d",TestDate)
  mpart=datepart("m",TestDate)
  ypart=datepart("yyyy",TestDate)
  
  Final_TestDate=dpart&"."&mpart&"."&ypart
  msgbox Final_TestDate