Date Hour Method


I create a function to use Hour function:

function createFileNames(steps,type,prefix,sufix,nml,dataIni)
	if type==1
		for t = 1:steps
			h = (t-1)*nml["step"]
			println(dataIni + Hour(h))

But when I run it I got the error:

ERROR: LoadError: UndefVarError: Hour not defined

If a try to run using interactive Julia it’s works. What happens?

You need a

using Dates

is my guess.

Hi Oheil. I make a mistake, instead using Dates I did import Dates

Now is working

1 Like

Of course you can use import, but than you have to use Hour like:

julia> import Dates

julia> Dates.Hour(5)
5 hours

import NiceStuff

brings only the module name into scope. Users would need to use NiceStuff.DOG , NiceStuff.Dog , and NiceStuff.nice to access its contents.

(just for completeness for others who may stumble into this thread)