Re: date

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Oct 10 2012 - 11:13:12 MDT

I styerted to write this before MH's response

====
Please look at the NCL function list.

All of NCL's date function are summarized under the "Date" category.

http://www.ncl.ucar.edu/

   (1) Click "Functions" and 'Category Listing'
   (2) Click "Date"

There is no 'yyyymmdd_to_day_of_year'.
There can not be a function for everything!
However, it is trivial to create your own.

undef ("ymd2doy")
function ymd2doy(yyyymmdd:integer)
local yyyy, mm, dd
begin
   yyyy = yyyymmdd/10000
   mm = (yyyymmdd - (yyyy*10000))/100
   dd = yyyymmdd%100
   return( day_of_year(yyyy,mm,dd) )
end

On 10/10/12 10:59 AM, Mary Haley wrote:
> You can use "day_of_year", but you need to split the value into separate
> year, month, and day integers.
>
> http://www.ncl.ucar.edu/Document/Functions/Built-in/day_of_year.shtml
>
> Here's some sample code:
>
> d = 20120305 ; assuming "d" is an int or a long
>
> year = toint(d/10000)
> month = toint((d-(year*10000))/100)
> day = toint(d-(year*10000)-(month*100))
>
> print("year = " + year)
> print("month = " + month)
> print("day = " + day)
>
> doy = day_of_year(year,month,day)
>
> print("doy = " + doy)
>
>
> If YYYYMMDD is a string, then convert it to an integer first using "toint".
>
> --Mary
>
> On Oct 10, 2012, at 10:40 AM, virginie hergault wrote:
>
>> Hi users,
>>
>> I would like to know how to convert a date YYYYMMDD to the day of the
>> year (between 1 and 365) ?
>> Is there a function available in ncl for this?
>>
>> Thank you,
>> Virginie
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Oct 10 11:13:19 2012

This archive was generated by hypermail 2.1.8 : Fri Oct 12 2012 - 15:38:19 MDT