Modify date from readtext

I have a need to readtext from a field in a form that is a date and time field. The format is DDHHMMZMMMYYYY. I need to read this text and advance the date by 48 hours (or 2 days) and enter that into another field on the form in the same format (DDHHMMZMMMYYY). I am able to readtext the field and typetext that information into another field but have not been able to modify the date to 48 hours or 2 days later. Any assistance would be helpful.

Comments

  • EggplantMattEggplantMatt ForumAdmin admin
    What do these characters represent? Can you provide an example of an actual date? You have Ms in two places. I could guess at what one of these dates actually looks like, but what I'm guessing doesn't really make sense to me. I can pretty much guarantee that eggPlant won't read this as a date; you'll have to split it up and reassemble it, then you'll be able to add 48 hours to the result and then reformat that the way that you need to type it back.
  • The first and second characters represent the day of the month
    The third and fourth characters represent the hour of the day (military time)
    The fifth and sixth characters represent the minutes
    Z is status and represents ZULU
    The eighth, ninth, and tenth characters represent the month abbreviated
    The final 4 characters represent the year
    Example: 130844ZOCT2017 = 13 October 2017 at 0844 (8:44 am)

    Thank you
  • Is anyone able to assist with this?
  • there you go
    put Zulu_toDateTime("131324ZNOV2017") into mydate
    put zuluDateTime(mydate + 2 days)
    
    function Zulu_toDateTime (zulustring)	
    	put characters 1 to 2 of zulustring  into day
    	put characters 3 to 4 of zulustring  into hour	
    	put characters 5 to 6 of zulustring  into min
    	put character 7 of zulustring into Z
    	put characters 8 to 10 of zulustring into month
    	put characters 11 to 14 of zulustring into year
    
    	return (month && day &"," && year && hour &":"& min)
    end Zulu_toDateTime
    
    
    function ZuluDateTime zdatetime	
    	return formattedTime("%d%H%MZ%b%Y",zdatetime)	
    end ZuluDateTime
    
  • Thank you for your reply. I have been working with the code provided but am not getting the proper results expected. First, I do not have the quoted value in the first line "131324ZNOV2017" to type into the script. This value is obtained from readtext of an image rectangle of another field. When I try to put that value in, I receive an error that the value is not a number. Any assistance is greatly appreciated.
  • ok, have you checked what the readtext is actually returning?
    You might need to tinker with the readtext settings to read all the characters as expected and then trim off any leading and trailing spaces.
  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    edited May 2018
    Hi, for future reference: you can simplify date calculations in a situation like this by expanding SenseTalk's list of known date/time formats to include a new format. Just insert the new format into the timeInputFormat global property:

    insert
    Once that is done, SenseTalk can recognize strings in that format as date/time values, and the task becomes very simple:

    set
Sign In or Register to comment.