Micro Focus QTP (UFT) Forums
Code for getting the next "the 1st in month" - 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: Code for getting the next "the 1st in month" (/Thread-Code-for-getting-the-next-the-1st-in-month)



Code for getting the next "the 1st in month" - janriis - 10-21-2009

Hi all

I need a code snippet that saves the next 1st date in a month in a variable NewDate. In this case the value of NewDate would be 11012009

Anyone who has an idea ?


RE: Code for getting the next "the 1st in month" - manabh - 10-21-2009

Hi,
Try this...
Code:
Dim TmpDate, NewDate
   TmpDate = DateAdd("mm", 1, Date)
   NewDate = DateSerial(Year(TmpDate), Month(TmpDate), 1)



RE: Code for getting the next "the 1st in month" - sreekanth chilam - 10-21-2009

Hi Janriis,

Try with the below way.
Code:
Dim TmpDate1,TmpDate2
   TmpDate1 = DateAdd("m",1, Date)
   TmpDate2 = DateSerial(Year(TmpDate1),Month(TmpDate1),1)
   NewDate=replace(TmpDate2,"/","")
   Msgbox NewDate

Hope it helps you.Smile


RE: Code for getting the next "the 1st in month" - janriis - 10-27-2009

Exactly what i needed, thx. How do i insert the value of NewDate into my txtDate field ?


RE: Code for getting the next "the 1st in month" - Tarik Sheth - 10-28-2009

Hi,

Assuming date field is of class webedit.
You can have Browser().Page().webedit().set NewDate