# Date Hour Method

**URL:** <https://discourse.julialang.org/t/date-hour-method/71978>\
**Category:** General Usage\
**Tags:** question, dates\
**Created:** [November 23, 2021, 9:00pm UTC](https://discourse.julialang.org/t/date-hour-method/71978 "2021-11-23T21:00:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luflarois](https://avatars.discourse-cdn.com/v4/letter/l/65b543/32.png) [@luflarois](https://discourse.julialang.org/u/luflarois)\
**Post date:** [November 23, 2021, 9:00pm UTC](https://discourse.julialang.org/t/date-hour-method/71978/1 "2021-11-23T21:00:27Z")

</div>

Hi.

I create a function to use Hour function:

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

```

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?

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [November 23, 2021, 9:07pm UTC](https://discourse.julialang.org/t/date-hour-method/71978/2 "2021-11-23T21:07:45Z")

</div>

You need a

```julia
using Dates

```

is my guess.

---

<div class="post-metadata">

**Author:** ![luflarois](https://avatars.discourse-cdn.com/v4/letter/l/65b543/32.png) [@luflarois](https://discourse.julialang.org/u/luflarois)\
**Post date:** [November 24, 2021, 10:55am UTC](https://discourse.julialang.org/t/date-hour-method/71978/4 "2021-11-24T10:55:13Z")

</div>

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

Now is working

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [November 24, 2021, 10:58am UTC](https://discourse.julialang.org/t/date-hour-method/71978/5 "2021-11-24T10:58:56Z")

</div>

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

```julia
julia> import Dates

julia> Dates.Hour(5)
5 hours

```

[https://docs.julialang.org/en/v1.6/manual/modules/#Standalone-using-and-import](https://docs.julialang.org/en/v1.6/manual/modules/#Standalone-using-and-import)

> ```julia
> 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)
