day of year from Igor dateTime object

Hi all,

I am trying to see if there is a way to get the day of year (DOY) from an Igor DateTime wave. 

Ideally I was hoping for something like secs2date(3636662400, option=DOY) gives 88.

https://en.wikipedia.org/wiki/ISO_8601#Ordinal_dates 


 

 

 

You could use something like this:

function DayOfYear()
   
    string strdate=Secs2Date(DateTime,-2)
    variable yyyy=str2num(StringFromList(0, strdate,"-"))
    variable mm=str2num(StringFromList(1, strdate,"-"))
    variable dd=str2num(StringFromList(2, strdate,"-"))
   
    return dateToJulian(yyyy, mm, dd) - dateToJulian(yyyy, 1, 1) + 1
end

 

In reply to by tony

or this

function DayOfYear(secs)
    variable secs
   
    variable yyyy, mm, dd
    sscanf Secs2Date(secs,-2), "%g-%g-%g", yyyy, mm, dd

    return dateToJulian(yyyy, mm, dd)-dateToJulian(yyyy, 1, 1)+1
end