Invalid date

Tags
advanced, dat, date, free, invalid

 
Thread Tools Search this Thread
# 1  
Old 09-26-2018
Invalid date

Hi, I have a function to calculate "yesterday" in format YYYYMMDD:

Code:
desa_ev9 # date +"%Y%m%d" --date "-1 day 20180701"
20180630

desa_ev9 # date +"%Y%m%d" --date "-1 day 20180720"
20180719

desa_ev9 # date +"%Y%m%d" --date "-1 day 20190101"
20181231

desa_ev9 # date +"%Y%m%d" --date "-1 day 20180913"
20180912

Works correctly but....

Code:
desa_ev9 # date +"%Y%m%d" --date "-1 day 20180812"
date: invalid date `-1 day 20180812'

What is the problem?




Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 09-26-2018 at 12:29 PM.. Reason: Added CODE tags.
# 2  
Old 09-26-2018
Welcome to the forum.

Works for me:
Code:
date +"%Y%m%d" --date "-1 day 20180812"
20180811

Anything special that you did between the before last and last command?
# 3  
Old 09-26-2018
Now I see, you want 1 day less than a given date.
It should work. I successfully checked with several versions of GNU date.
If even
Code:
date +"%Y%m%d" --date "20180812 - 1 day"

does not work, then I suspect a bug in your date program.

Last edited by MadeInGermany; 09-26-2018 at 04:22 PM..

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Find invalid character pallvi_mahajan Shell Programming and Scripting 18 10-29-2014 10:34 PM
Converting a date to friday date and finding Min/Max date 2001.arun Shell Programming and Scripting 10 07-30-2012 12:08 PM
Valid and invalid date in the file bmk Shell Programming and Scripting 7 05-31-2012 06:43 PM
date: invalid date Jcpratap Shell Programming and Scripting 1 05-24-2012 11:14 AM
Invalid Character lawrance_ps Linux 1 01-16-2011 10:19 AM
?Invalid Command Olivia Shell Programming and Scripting 2 01-08-2011 11:40 PM
invalid null command jdsignature88 Shell Programming and Scripting 1 07-08-2010 05:04 AM
Invalid Command Name sudharsan23 Shell Programming and Scripting 3 04-15-2010 04:42 AM
id: invalid user name mokkan Solaris 1 09-24-2009 11:18 AM
op is invalid lipun4u Shell Programming and Scripting 2 08-29-2009 08:15 AM
date: invalid date `19010101' freizl Shell Programming and Scripting 8 01-22-2009 12:04 AM
SFTP Invalid IP ronnie_uk Shell Programming and Scripting 2 09-18-2008 03:26 AM
invalid link Hank Post Here to Contact Site Administrators and Moderators 4 06-29-2008 04:20 PM
stty: : Invalid argument tony3101 Shell Programming and Scripting 2 03-16-2006 06:33 PM