Function for day of the year
    8 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    amateurintraining
 el 11 de Oct. de 2017
  
    
    
    
    
    Editada: per isakson
      
      
 el 11 de Oct. de 2017
            How do I write a function that responds the days of the year when given a certain date? For example, January 7th, 2017 would respond 7 as that is the 7th day of the year. (This is also accounting for leap years.)
0 comentarios
Respuesta aceptada
  per isakson
      
      
 el 11 de Oct. de 2017
        
      Editada: per isakson
      
      
 el 11 de Oct. de 2017
  
      Introduced in R2014b
>> day( datetime('07-Jan-2017', 'InputFormat', 'dd-MMM-yyyy' ), 'dayofyear' )
ans =
     7
"accounting for leap years" If not, shame on The MathWorks!
>> day( datetime('01-Mar-2017', 'InputFormat', 'dd-MMM-yyyy' ), 'dayofyear' )
ans =
    60
>> day( datetime('01-Mar-2016', 'InputFormat', 'dd-MMM-yyyy' ), 'dayofyear' )
ans =
    61
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Dates and Time en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

