package main import "fmt" import "log" import "os" import "time" func main() { if len(os.Args) != 3 { log.Fatalln("usage datediff ") } FORMAT := "02/01/2006" d1, err := time.ParseInLocation(FORMAT, os.Args[1], time.Local) if err != nil { log.Fatalln("Invalid date 1", err) } d2, err := time.ParseInLocation(FORMAT, os.Args[2], time.Local) if err != nil { log.Fatalln("Invalid date 2", err) } dur := d2.Sub(d1) //fmt.Println(dur.String()) fmt.Println(int64(dur / (24 * time.Hour))) }