Sponsored Content
Full Discussion: Invalid date
Top Forums UNIX for Advanced & Expert Users Invalid date Post 303023954 by augreen on Wednesday 26th of September 2018 09:53:43 AM
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.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SFTP Invalid IP

Hi, I have an SFTP script which is called from another run script: When the SFTP process is run we passed through an invalid ip address to check the error logging and to ensure everything is working as expected. Below is a sample of the code in the script: $RUNSOCKS... (2 Replies)
Discussion started by: ronnie_uk
2 Replies

2. Shell Programming and Scripting

date: invalid date `19010101'

why date -d "19010101" gets error " date: invalid date `19010101' " but date -d "19020101" is fine? Any approach to fix that? Thank you. (8 Replies)
Discussion started by: freizl
8 Replies

3. Shell Programming and Scripting

op is invalid

In the following code a= echo $? echo $? Why the op is (2 Replies)
Discussion started by: lipun4u
2 Replies

4. Solaris

id: invalid user name

Hello, We run solaris 8 with nis+, when I do niscat, I can see the user's information, but when I do id from the domain it is saying invalid user. What may be the problem? id: invalid user name: "abyu789" (1 Reply)
Discussion started by: mokkan
1 Replies

5. Shell Programming and Scripting

Invalid Command Name

I have telnet to a machine and executed some commands in it. pls see below : #!/usr/bin/expect spawn telnet 170.10.11.1 2100 expect "login:" send username\r expect "password:" send password\r expect "$" send "touch filetest\r" expect "$" send exit\r expect... (3 Replies)
Discussion started by: sudharsan23
3 Replies

6. Shell Programming and Scripting

?Invalid Command

when i am executing the script i am getting ?Invalid command though the script is right. Could any one please let me know how to overcome this problem. Urgent Please Thanks a lot in advance (2 Replies)
Discussion started by: Olivia
2 Replies

7. Shell Programming and Scripting

date: invalid date

Hi All, I am trying to convert the date of all files under a directory in seconds, PFB script a=`ls -lrt | wc -l` echo $a for ((i=1;i<=$a;i++)) do A=`ls -lrt | awk '{print $6,$7,$8}' | head -$i | tail -1` echo ${A} date -d '${A}' +%s donebut I am getting error date: invalid date... (1 Reply)
Discussion started by: Jcpratap
1 Replies

8. Shell Programming and Scripting

Valid and invalid date in the file

Hi All, How to validate the 4th column,it is date column in the file, if it valid move to valid file else moved invalid file. 9f680174-cb87|20077337254|0|20120511|N 9f680174-cb88|20077337254|0|20120534|N i want two file valid.txt and invalid.txt Thanks, (7 Replies)
Discussion started by: bmk
7 Replies

9. Shell Programming and Scripting

Converting a date to friday date and finding Min/Max date

Dear all, I have 2 questions. I have a file with many rows which has date of the format YYYYMMDD. 1. I need to change the date to that weeks friday date(Ex: 20120716(monday) to 20120720). Satuday/Sunday has to be changed to next week friday date too. 2. After converting the date to... (10 Replies)
Discussion started by: 2001.arun
10 Replies

10. Shell Programming and Scripting

Date: invalid date trying to set Linux date in specific format

i try to set linux date & time in specific format but it keep giving me error Example : date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" or date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" keep giving me this error : date: invalid date ‘19-01-2017 00:05:01' Please use CODE tags... (7 Replies)
Discussion started by: umen
7 Replies
curl_getdate(3) 						  libcurl Manual						   curl_getdate(3)

NAME
curl_getdate - Convert an date in a ASCII string to number of seconds since January 1, 1970 SYNOPSIS
#include <curl/curl.h> time_t curl_getdate(char *datestring, time_t *now"); DESCRIPTION
This function returns the number of seconds since January 1st 1970, for the date and time that the datestring parameter specifies. The now parameter is there and should hold the current time to allow the datestring to specify relative dates/times. Read further in the date string parser section below. PARSING DATES AND TIMES
A "date" is a string, possibly empty, containing many items separated by whitespace. The whitespace may be omitted when no ambiguity arises. The empty string means the beginning of today (i.e., midnight). Order of the items is immaterial. A date string may contain many flavors of items: calendar date items This can be specified in a number of different ways. Including 1970-09-17, 70-9-17, 70-09-17, 9/17/72, 24 September 1972, 24 Sept 72, 24 Sep 72, Sep 24, 1972, 24-sep-72, 24sep72. The year can also be omitted, for example: 9/17 or "sep 17". time of the day items This string specifies the time on a given day. Syntax supported includes: 18:19:0, 18:19, 6:19pm, 18:19-0500 (for specifying the time zone as well). time zone items Specifies international time zone. There are a few acronyms supported, but in general you should instead use the specific realtive time compared to UTC. Supported formats include: -1200, MST, +0100. day of the week items Specifies a day of the week. If this is mentioned alone it means that day of the week in the future. Days of the week may be spelled out in full: `Sunday', `Monday', etc or they may be abbreviated to their first three letters, optionally followed by a period. The special abbreviations `Tues' for `Tuesday', `Wednes' for `Wednesday' and `Thur' or `Thurs' for `Thursday' are also allowed. A number may precede a day of the week item to move forward supplementary weeks. It is best used in expression like `third mon- day'. In this context, `last DAY' or `next DAY' is also acceptable; they move one week before or after the day that DAY by itself would represent. relative items A relative item adjusts a date (or the current date if none) forward or backward. Example syntax includes: "1 year", "1 year ago", "2 days", "4 weeks". The string `tomorrow' is worth one day in the future (equivalent to `day'), the string `yesterday' is worth one day in the past (equivalent to `day ago'). pure numbers If the decimal number is of the form YYYYMMDD and no other calendar date item appears before it in the date string, then YYYY is read as the year, MM as the month number and DD as the day of the month, for the specified calendar date. RETURN VALUE
This function returns zero when it fails to parse the date string. Otherwise it returns the number of seconds as described. AUTHORS
Originally written by Steven M. Bellovin <smb@research.att.com> while at the University of North Carolina at Chapel Hill. Later tweaked by a couple of people on Usenet. Completely overhauled by Rich $alz <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990. SEE ALSO
BUGS
Surely there are some, you tell me! libcurl 7.0 5 March 2001 curl_getdate(3)
All times are GMT -4. The time now is 12:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy