I have two date fields and I want to convert them to a format of "YYYY-MM-DD" and am successful in converting the first date but when the code comes to convert the second date, it gives a very weird result.
         put empty into tStart
         put empty into fDate
         put field "startDate" into fDate
         convert fDate to dateitems 
         put (the item 1 of fDate) & "-" & (the item 2 of fDate) & "-" & (the item 3 of fDate) into tStart
         
         set the itemDelimiter to "-"
         put format("%02s", item 2 of tStart) into item 2 of tStart
         put format("%02s", item 3 of tStart) into item 3 of tStart
         
****** RESULT = 2013-01-01 ******* 
         put empty into tEnd
         put field "endDate" into eDate
         convert eDate to dateitems 
         put (the item 1 of eDate) & "-" & (the item 2 of eDate) & "-" & (the item 3 of eDate) into tEnd
         
         set the itemDelimiter to "-"
         put format("%02s", item 2 of tEnd) into item 2 of tEnd
         put format("%02s", item 3 of tEnd) into item 3 of tEnd
******** RESULT = 2013,1,31,0,0,0,5-00-00 ********
If I swap the two pieces of code around, the same things happens. Always the second date that has this issue?
			
			
									
									
						Date manipulation oddity
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Date manipulation oddity
Ouh la la... don't bother... keep it simple !   
 
From Date&Time library of Sarah.
http://www.troz.net/rev/stacks/DateTime.rev
on mouseup
answer englishToSQLdate ()
end mouseup
			
			
									
									
						 
 From Date&Time library of Sarah.
http://www.troz.net/rev/stacks/DateTime.rev
Code: Select all
function englishToSQLdate pDate
   if pDate is empty then put the short english date into pDate
   convert pDate from short english date to dateItems
   put item 2 of pDate into m
   if m < 10 then put "0" before m
   put item 3 of pDate into d
   if d < 10 then put "0" before d
   return item 1 of pDate & "-" & m & "-" & d
end englishToSQLdate()answer englishToSQLdate ()
end mouseup
Re: Date manipulation oddity
Hi Nicoloose,
your second date does not work because you forgot to set the itemDelimiter to "," after the first conversion and before the second conversion.
It should work if you putbefore
Kind regards
Bernd
			
			
									
									
						your second date does not work because you forgot to set the itemDelimiter to "," after the first conversion and before the second conversion.
It should work if you put
Code: Select all
set the itemDelimiter to ","Code: Select all
put empty into tEndBernd
Re: Date manipulation oddity
Simplicity and logic are not among the lines of the things in me!
Thanks for the help!
			
			
									
									
						Thanks for the help!
Re: Date manipulation oddity
LOL! But you learn fast.Simplicity and logic are not among the lines of the things in me!

Jacqueline Landman Gay         |     jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
						HyperActive Software | http://www.hyperactivesw.com
