{"identifier":33535,"topic":"Commands","name":"convert","text":"<code>convert {<i>value<\/i><\/code> <code>|<i>container<\/i>}[from  \u00ac  <i>formatName<\/i>  <\/code>[<code>and <i>formatName<\/i><\/code> ] ] <code>  \u00ac  to <i>formatName<\/i> <\/code>  [<code>and <i>formatName<\/i><\/code> ] <br><br>\n\n The<code> convert <\/code>command changes a value expressed as a valid date, time, or date and time format to another format. <br><br>\n\n You use <code>and <i>formatName<\/i> <\/code>in combination with the first <i><code>formatName<\/i><\/code> to convert a value to any two formats (often the  date and time). <br>\n<br>\nThe  form<code> convert <i>value<\/i><\/code> <code> to <i>formatName<\/i> <\/code>returns the converted <i><code>value<\/i> <\/code> in the local variable<code> it<\/code>.<code> <\/code>The form <code>convert <i>container<\/i> to <i>formatName<\/i> <\/code>converts a value in a chunk or <i><code>container<\/i> <\/code> (including variables) and places the result in that chunk or container. <br><br>\n\n You use the form<code> from <i>format<\/i> <\/code> in situations where you don't want HyperCard to do the conversion automatically. <br>\n","related":{"27092":null,"11187":null,"24266":null,"55207":"date","66404":"time"},"examples":"convert \"1\/1\/1960\" to seconds -- the result goes into the variable it\nconvert \"1\/1\/1960\" to seconds and long date\nconvert (the seconds - startSeconds) to abbreviated time\n\nconvert bkgnd field \"date\" to seconds -- the result goes into the field\nconvert last word of field \"Info\" to short date\n\nconvert totalTime to abbreviated time -- the result goes into totalTime\n\nconvert field 1 from date to dateItems\nconvert myVar from seconds to long date\nconvert card field \"Date and Time\" from date and time to dateItems","demo":"on daysOld\n   repeat until birthTime is a date\n     put \"What is your birthdate?\" after sayIt\n     ask sayIt with the short date\n     if (it is empty) OR (the result is \"Cancel\") then exit daysOld\n     put it into birthTime\n     if birthTime is not a number\n     then put birthTime && \"is not a valid date.\" & return into sayIt\n   end repeat\n   <b>convert<\/b> birthTime to seconds -- change birthTime to seconds\n   <b>convert<\/b> the date to seconds  -- get the current date\n   put (it - birthTime) \/ 86400 into daysOld   -- 86400 seconds in 1 day\n   <b>convert<\/b> birthTime to long date\n   answer \"You were born on\" && birthTime & \", and you are currently\" &&\u00ac\n   daysOld && \"days old.\"\n end daysOld\n ","debug":{"9":["convert {value |cont"],"10":["The  form convert va"]}}