Page 1 of 2

Error command DATE

PostPosted: 2019-05-23 23:51
by elkergb
Good night.
When executing the syntax below returns error, however if I put day 02 or 04 it works out. Only with day 03 that gives error.
date -d "20191103" +% d% m% Y
I tested in Debian 9 and Ubuntu 18.04, both have the same error, but when run in OpenSuse 12.3 it works!
can you help me?
Thank you very much in advance.

Re: Error command DATE

PostPosted: 2019-05-24 01:50
by GarryRicketson
You say both have the same error, but what is the error, what does it say ?

Debian is not Opensuse, neither is Ubuntu, so it is logical that a command that works on opensuse might not work on either other distro.

Also, for Debian, see the manual for date:
Code: Select all
man date

Your operands don't look right to me, the error message should clarify on that, but you do not show it.
Also it really is not clear what you are trying to do,
what output you expect or want,..
Here is one example:
Code: Select all
garry@debian:~$ date -d "20191103" "+%d%m%y"
031119
garry@debian:~$ 

Or is this what you want ?
Code: Select all
garry@debian:~$ date -d "20191103" "+%y%m%d"
191103
garry@debian:~$ 

Or this :
Code: Select all
garry@debian:~$ date -d "20191103" "+%Y%m%d"
20191103
garry@debian:~$ 

Do you need more examples ?:
Code: Select all
 garry@debian:~$ date -d "20191103" "+ %d %m %Y"
 03 11 2019
garry@debian:~$ 

======
Code: Select all
garry@debian:~$ date -d "20191103" "+ %D %M %Y"
 11/03/19 00 2019
garry@debian:~$ 

You can try even more various methods, and see what the out put is, if none of the above are what you want.
To sum it up, the syntax that you claim works on opensuse, will not work on Debian, ... But yes, even on Debian, one can get the output with 03, as the day,..if they take the time to read a little, ...I did not know the answer when I started, but a quick search, and a few trial by error, combined with reading the manual, ...just goes to show.
I am not familiar with opensuse, but I find it hard to believe that syntax even works on opesuse.

Re: Error command DATE

PostPosted: 2019-05-24 02:04
by GarryRicketson
Additional :

Post by elkergb » 2019-05-23 18:51
Good night.
When executing the syntax below returns error, however if I put day 02 or 04 it works out. Only with day 03 that gives error.
date -d "20191103" +% d% m% Y
I tested in Debian 9 and Ubuntu 18.04, both have the same error, but when run in OpenSuse 12.3 it works!
can you help me?

It does not and can not work as you show it, and it does not matter if you use 02,04, etc, it is just plain bad syntax, as the error messages show,


Code: Select all
garry@debian:~$ date -d "20191104" +% d% m% Y
date: extra operand ‘d%’
Try 'date --help' for more information.
garry@debian:~$ date -d "20191102" +% d% m% Y
date: extra operand ‘d%’
Try 'date --help' for more information.
garry@debian:~$ 


I really don't believe the above would work on opensuse either, and that kind of makes me wonder,... so Can any Opensuse users confirm ? Is that really a correct syntax on Opensuse ? Just wondering

Re: Error command DATE

PostPosted: 2019-05-24 12:04
by trinidad
Simply you can't print something to standout that's not there i/e something% can't work. Needs to be %something because something is in memory.

TC

Re: Error command DATE

PostPosted: 2019-05-24 12:44
by GarryRicketson
Thanks, but it seems the OP claims they can on opensuse,
elkergb » but when run in OpenSuse 12.3 it works!

I think maybe they are "pulling our leg", as they say.....I don't think it works on opensuse, either. In fact, now that I think about it, Why did the OP even mention opensuse, if they really are trying to get help with Debian ?

Any way, variations of the 'date' command all work just fine on Debian, if the syntax is written correctly.

Re: Error command DATE

PostPosted: 2019-05-27 20:47
by elkergb
When I put the message in Translator she misconfigured the syntax, so I'm sending the prints. In summary, converting to Debin / Ubuntu gives error, but in Opensuse not. Only one specific day as you can see on the prints.
Answering some colleagues:
- The error that appears is "Invalid Date"
- syntax works on all the above distributions
Peço desculpas se novamente o tradutor não funcionar.

Re: Error command DATE

PostPosted: 2019-05-27 21:55
by GarryRicketson
Thank you for the additional info, and clarifying.
This seems strange to me, I can not duplicate it :
Code: Select all
garry@debian:~$ date -d"20191103" +%d/%m/%Y
03/11/2019
garry@debian:~$ lsb_release -a
No LSB modules are available.
Distributor ID:   Debian
Description:   Debian GNU/Linux buster/sid
Release:   testing
Codename:   buster
garry@debian:~$ uname -a
Linux debian 4.19.0-4-amd64 #1 SMP Debian 4.19.28-2 (2019-03-15) x86_64 GNU/Linux
garry@debian:~$
 

As you can see , I don't get the error, Can you please show us the out put from ? :
Code: Select all
lsb_release -a

Just the Debian, the other distros are of no importance. I have no idea why on your system the command does not work as it should, it does on mine, but that does not mean there is not some kind of problem, maybe it only effects certain hardware, IE: PC, keyboard, etc,...
=== edit ====
Also, are you trying to set the date and time, ? or Why are you needing this date format to say
Code: Select all
03/11/2019
?

Re: Error command DATE

PostPosted: 2019-05-31 12:53
by trinidad
Also run echo $0 and let us know what shell is in use when you get the error. I've seen errors because of shell resets, but never like this. I can't duplicate it on stable.

TC

Re: Error command DATE

PostPosted: 2019-05-31 13:17
by GarryRicketson
I had not noticed earlier, but the OP is using a older kernel version, based on the "uname" out put, so that kind of explains why I can't duplicate it.

Re: Error command DATE

PostPosted: 2019-05-31 13:27
by None1975
And i don't get the error:
Code: Select all
date -d"20191103" +%d/%m/%Y
03/11/2019
lsb_release -a
No LSB modules are available.
Distributor ID:   Debian
Description:   Debian GNU/Linux 9.9 (stretch)
Release:   9.9
Codename:   stretch
uname -a
Linux jwm 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u2 (2019-05-13) x86_64 GNU/Linux


My shell is zsh
Code: Select all
echo $SHELL
/bin/zsh

Re: Error command DATE

PostPosted: 2019-05-31 14:06
by trinidad
Code: Select all
trinidad@debianamd1:~$ lsb_release -a
No LSB modules are available.
Distributor ID:   Debian
Description:   Debian GNU/Linux 9.6 (stretch)
Release:   9.6
Codename:   stretch
trinidad@debianamd1:~$ echo $0
bash
trinidad@debianamd1:~$ uname -a
Linux debianamd1 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 GNU/Linux
trinidad@debianamd1:~$ date -d"20191103" +%d/%m/%Y
03/11/2019
trinidad@debianamd1:~$ ps -p "$$"
  PID TTY          TIME CMD
 4547 pts/0    00:00:00 bash
trinidad@debianamd1:~$


Run the last command and get back to us.

TC

Re: Error command DATE

PostPosted: 2019-06-01 12:17
by trinidad
Thinking about this a bit, and I'm not sure if you're serious here, or just playing around, but the SUSE code is in a C shell, though that is no reason why there would be errors in Debian's BASH. Are you running something or building with XML and not switching back shells in Debian? It has to be a shell error, almost like it's a web extension 103 error code without the message. Some software in between is causing the entry to be declared invalid. Make sure your shell in Debian is BASH and run the date command again. It would be nice to identify the cause if possible in case it is an odd bug of some sort.

TC

Re: Error command DATE

PostPosted: 2019-06-01 13:53
by Head_on_a_Stick
I think the OP is winding us up and has a hidden unicode character in the posted screenshot that is making the command fail.

@OP: disprove me by posting your example in code tags.

Re: Error command DATE

PostPosted: 2019-06-01 14:11
by Bloom
It works just fine in Debian 10 as well, but as indidcated before you need to eliminate the spaces in the formatting parameter:
Code: Select all
date -d "20191103" +%d/%m/%Y

This produces:
03/11/2019

Re: Error command DATE

PostPosted: 2019-06-01 14:33
by trinidad
@None 1975 $SHELL gives the default shell. $0 gives the current shell.

@HoaS You may right.

@OP Post your output code running the last command as requested.

TC