# Comparing 2 dates

**URL:** <https://discourse.gohugo.io/t/comparing-2-dates/23989>\
**Category:** support\
**Created:** [March 13, 2020, 5:32pm UTC](https://discourse.gohugo.io/t/comparing-2-dates/23989 "2020-03-13T17:32:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Jeffery](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/james_jeffery/32/9594_2.png) [@James\_Jeffery](https://discourse.gohugo.io/u/James_Jeffery)\
**Post date:** [March 13, 2020, 5:32pm UTC](https://discourse.gohugo.io/t/comparing-2-dates/23989/1 "2020-03-13T17:32:40Z")

</div>

I have a .csv file used to populate a table. The first column is a date string in the following format “13/3/2020”. I would like to compare it to todays date, in the same format.

I’m having a hard time getting this to work. Here’s what I’ve tried:

```
{{ define "main" }}
<div class="container mx-auto markdown">
	<h1 class="text-4xl font-bold mt-4 mb-1 leading-none">{{ .Title }}</h1>
	{{ $url := "http://cowid.netlify.com/data/full_data.csv" }}
	{{ $sep := "," }}
	{{ $t := (time now) }}

	{{ range $i, $r := getCSV $sep $url }}

	{{ where $t.Equal (time ($r 0)) }}
	<p>{{ index $r 1 }}</p>

	{{ end }}

	{{ .Content }}
</div>
{{ end }}

```

The error I get is:

```auto
execute of template failed: template: _default\statistics.html:10:12: executing "main" at <$t.Equal>: wrong number of args for Equal: want 1 got 0

```

Any idea’s how to get this working. Go is very alien to me.

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [March 14, 2020, 9:32am UTC](https://discourse.gohugo.io/t/comparing-2-dates/23989/2 "2020-03-14T09:32:36Z")

</div>

> [@James\_Jeffery](#):
>
> `{{ where $t.Equal (time ($r 0)) }}`

I’m not sure what you are trying to do here, but this looks wrong.

[`where`](https://gohugo.io/functions/where/) operates on a collection, and I think you are missing an `index` before `$r 0`?

```auto
{{ $t := (time now).Format "2006-01-02" }}
{{ range $i, $r := getCSV $sep $url }}
{{ if gt $i 0 }} <!-- skip header row -->
  {{ $rtime := (time (index $r 0)).Format "2006-01-02" }}
  {{ $t }} / {{ $rtime }}
  {{ if eq $t $rtime }} <!-- check if eq -->
    Equal to today; do stuff.
  {{ end }}
{{ end }}

```
