#!/bin/sh

if [ "$#" = "1" ]; then
	DAYFROM="$1"
	DAYTO=`date +"%Y-%m-%d"`
else
  if [ "$#" = "2" ]; then
	DAYFROM="$1"
	DAYTO="$2"
  else
	echo "usage: $0 <day-from> [<day-to>]"
	echo "	(Format for days: YYYY-MM-DD or MM/DD/YYYY)"
	exit;
  fi
fi

echo "select ('$DAYTO'::date - '$DAYFROM'::date) as Days;" |  psql
