Ask a Question

can aqDateTime.GetMonth return a 2 character month? Same with GetDay?

SOLVED
grutherford
Occasional Contributor

can aqDateTime.GetMonth return a 2 character month? Same with GetDay?

I need to get a 2 character month and day from an input string (e.g., 20180109).  The aqDateTime.GetMonth strips the leading 0 when the month or day is less than 10.

3 REPLIES 3
Marsha_R
Community Hero

You can wrap the result in the string format that you want to use:

 

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/format-specifiers...


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
grutherford
Occasional Contributor

Thank you Marsha_R!

HKosova
SmartBear Alumni (Retired)

You can use aqConvert.DateTimeToFormatStr with the %m (month) or %d (day) specifiers:

aqConvert.DateTimeToFormatStr(dateTime, "%m")

or aqString.Format as @Marsha_R suggested:

aqString.Format("%02d", aqDateTime.GetMonth(dateTime))

Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: