SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 7 of 7
  1. #1
    Junior Member
    Join Date
    Nov 2007
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    How to convert the String to Date Format

    Hi

    Can anybody tell me the scipt for

    convert a Static Text(String) for ex:"07/11/07"
    to Date format (dd/mm/yy) with the next day
    the answer should be 08/11/07

    i searched in the silk test help but it is showing only yyyy/mm/dd be converted to date , but how can i convert this


    i am waiting for your reply

  2. #2
    Senior Member
    Join Date
    Feb 2003
    Location
    Romania
    Posts
    163
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to convert the String to Date Format


    Hi Adidelareddy2007 ,

    Here is e sequence for your problem:
    Code:
    [-] testcase tc() appstate none
    	[-] //From Date Help 
    		[ ] //You can generate a DATE constant by specifying a 
    		[ ] //date as a string and then casting the string as a
    		[ ] // DATE data type. The string must have the following format:
    		[ ] //"YYYY-MM-DD"
    	[ ] string sOriginalDate = "07/11/07" //dd/mm/yy
    	[ ] string sDateInt 
    	[ ] string sFinalDate
    	[ ] datetime dtDate
    	[ ] 
    	[ ] int iDays =1 //increment day
    	[ ] //invert original date
    	[ ] sDateInt = Right (sOriginalDate, len(sOriginalDate))
    	[ ] //change / in -
    	[ ] sDateInt  = StrTran (sOriginalDate, "/", "-")
    	[ ] //convert string in datetime
    	[ ] dtDate = [datetime]sDateInt
    	[ ] print (" sDate = {sDateInt} ")
    	[ ] //inc day
    	[ ] dtDate = AddDateTime (dtDate , iDays )
    	[ ] //format final date
    	[ ] sFinalDate = FormatDateTime (dtDate,  "dd/mm/yy")
    	[ ] print("  sFinalDate = { sFinalDate}")
    	[ ] 
    It possible to do more simple...:-)
    With regards,
    nelumoldovan49,

  3. #3
    Senior Member
    Join Date
    Feb 2003
    Location
    Romania
    Posts
    163
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to convert the String to Date Format

    Hi Adidelareddy2007 ,

    Excuse me,above, I posted not final version.
    This is:
    [-] testcase tc() appstate none
    [-] //From Date Help
    [ ] //You can generate a DATE constant by specifying a
    [ ] //date as a string and then casting the string as a
    [ ] // DATE data type. The string must have the following format:
    [ ] //"YYYY-MM-DD"
    [ ] string sOriginalDate = "07/11/07" //dd/mm/yy
    [ ] string sDateInt
    [ ] string sFinalDate
    [ ] datetime dtDate
    [ ]
    [ ] int iDays =1 //increment day
    [ ]
    [ ] print (" sOriginalDate = {sOriginalDate} ")
    [ ] //invert original date
    [ ] sDateInt = Right (sOriginalDate, len(sOriginalDate))
    [ ] //change / in -
    [ ] sDateInt = StrTran (sDateInt, "/", "-")
    [ ] //convert string in datetime
    [ ] dtDate = [datetime]sDateInt
    [ ] //inc day
    [ ] dtDate = AddDateTime (dtDate , iDays )
    [ ] //format final date
    [ ] sFinalDate = FormatDateTime (dtDate, "dd/mm/yy")
    [ ] print(" sFinalDate = { sFinalDate}")


    With regards,
    nelumoldovan49,

  4. #4
    Member
    Join Date
    Mar 2007
    Posts
    54
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to convert the String to Date Format

    MakeDateTime may fit your requirement.

    MakeDateTime

    Generates and returns a DATETIME value constructed from the arguments you supply.


  5. #5
    Junior Member
    Join Date
    Nov 2007
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to convert the String to Date Format

    Thanks nelumoldovan49

    yah its working fine

    Ravinder

  6. #6
    Junior Member
    Join Date
    Jun 2011
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to convert the String to Date Format

    in the above case how can we convert the date if its in the format of "MM/DD/YYYY". How can we make it into the standard DATE data type format "YYYY/MM/DD"

  7. #7
    Senior Member
    Join Date
    Jan 2005
    Location
    UK
    Posts
    334
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to convert the String to Date Format

    Read the help files on "Date and Time Manipulation", and if you read and understand the lines of code, you will see a function called FormatDateTime.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 9.38%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 10:47 PM.

Copyright BetaSoft Inc.