Micro Focus QTP (UFT) Forums

Full Version: Getting System Date in Checkpoint
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I needed to know how I Can put a Checkpoint to Validate my system Date. As scripts are run every day the system date changes so how can i put a checkpoint in there.

Also I would like to know about output checkpoints, how do they work?

Thanks,
Nilu.
you can use Time function to get current system time. And insert a conditional statement. Just a thought...
When you say system date, do you mean the date in your application?

As for output checkpoints: I think QTP's documentation would be a better source.
No, I mean the Current Date. That Date I am able to get but how do I put it in a Checkpoint?
I can think of two options, either custom make your checkpoint using if else statement
OR

parameterize your checkpoint to use datatable value and use datatable formula
=NOW()

to get date, right click on datatable cell > Format > date(dynamic)
Hey Ankur,
I did what you mentioned to get current Date in a Checkpoint but it still fails because it looks at system time & fails by few milliseconds. I s there a way that I can ignore the time factor & just look at the date so that the checkpoint does not fail.
thanks,
Nilu.
You can use Date() function wherever you want to call the System Date
For the above specified one i ma not getting the options of the date and other when i right click on the datatable
Hi,

You can achieve you goal by using the below ways:

1.
Code:
User formatdatetime, if your date is in the format of mm/dd/yyyy.
msgbox(formatdatetime(date()))  'displays date in 7/19/2008
msgbox(formatdatetime(date,2))  'displays date in 7/19/2008
2. Or else you can use some logic to put the date in your required format, here use datepart function:
I used the below code to verify the "Current Time:"(date part) displayed in the top right corner of this page.

Code:
dayPart=datepart("d",date())
monthPart=datepart("m",date())
yearPart=datepart("yyyy",date())

If dayPart<10 Then
    dayPart="0"&dayPart
End If

If monthPart<10 Then
    monthPart="0"&monthPart
End If

reqDate=monthPart&"-"&dayPart&"-"&yearPart
msgbox(reqDate)