Micro Focus QTP (UFT) Forums
Returned Date Format - 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: Returned Date Format (/Thread-Returned-Date-Format)



Returned Date Format - mv8167 - 07-01-2011

I have the following code:

Code:
eDate = DateAdd("d",-1,Now())
eDate = FormatDateTime(eDate,2)

which returns the value 6/29/2011

but I need the zero in front of the six. I need 06/29/2011 returned.

Any ideas is this is possible?

thx for looking.


RE: Returned Date Format - rajpes - 07-04-2011

Code:
eDate = DateAdd("d",-1,Date)

If len(month(eDate))=1 then
eDate=0&eDate
end if[hr]



RE: Returned Date Format - mv8167 - 07-06-2011

Rajpes,

Thx again...

Your solution is way easier then my final solution:

Code:
TodayDateMinusOne = DateAdd("d",-1,Now())
    eDate = FormatDateTime(TodayDateMinusOne, 2)
    'Call DateManipulate(eDate)  Insure date is MM/DD/YYYY format

    'Function DateManipulate(eDate)
    'Insure date is MM/DD/YYYY format
    Set MyDate = DotNetFactory.CreateInstance("System.DateTime")
    Set oDate = MyDate.Parse(eDate)
    DateManipulate = oDate.ToString("MM/dd/yyyy")
    eDate = DateManipulate
    'msgbox DateManipulate
    Set MyDate = Nothing
    'End Function



lol


RE: Returned Date Format - rajpes - 07-06-2011

ya, you don't need to complicate so much, just use simple logic