Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Error command DATE

Here you can discuss every aspect of Debian. Note: not for support requests!
Post Reply
Message
Author
elkergb
Posts: 2
Joined: 2019-05-23 23:39

Error command DATE

#1 Post 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.

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Error command DATE

#2 Post 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.
Last edited by GarryRicketson on 2019-05-24 02:33, edited 1 time in total.

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Error command DATE

#3 Post 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

trinidad
Posts: 290
Joined: 2016-08-04 14:58
Been thanked: 14 times

Re: Error command DATE

#4 Post 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
You can't believe your eyes if your imagination is out of focus.

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Error command DATE

#5 Post 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.

elkergb
Posts: 2
Joined: 2019-05-23 23:39

Re: Error command DATE

#6 Post 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.
Attachments
print_opensuse.png
print_opensuse.png (26.13 KiB) Viewed 11435 times
print_ubuntu.png
print_ubuntu.png (22.69 KiB) Viewed 11435 times
print_debian.png
print_debian.png (18.22 KiB) Viewed 11435 times

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Error command DATE

#7 Post 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 
?

trinidad
Posts: 290
Joined: 2016-08-04 14:58
Been thanked: 14 times

Re: Error command DATE

#8 Post 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
You can't believe your eyes if your imagination is out of focus.

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Error command DATE

#9 Post 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.

User avatar
None1975
df -h | participant
df -h | participant
Posts: 1388
Joined: 2015-11-29 18:23
Location: Russia, Kaliningrad
Has thanked: 45 times
Been thanked: 65 times

Re: Error command DATE

#10 Post 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
OS: Debian 12.4 Bookworm / DE: Enlightenment
Debian Wiki | DontBreakDebian, My config files on github

trinidad
Posts: 290
Joined: 2016-08-04 14:58
Been thanked: 14 times

Re: Error command DATE

#11 Post 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
You can't believe your eyes if your imagination is out of focus.

trinidad
Posts: 290
Joined: 2016-08-04 14:58
Been thanked: 14 times

Re: Error command DATE

#12 Post 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
You can't believe your eyes if your imagination is out of focus.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Error command DATE

#13 Post 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.
deadbang

User avatar
Bloom
df -h | grep > 90TiB
df -h | grep > 90TiB
Posts: 504
Joined: 2017-11-11 12:23
Been thanked: 26 times

Re: Error command DATE

#14 Post 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

trinidad
Posts: 290
Joined: 2016-08-04 14:58
Been thanked: 14 times

Re: Error command DATE

#15 Post 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
You can't believe your eyes if your imagination is out of focus.

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Error command DATE

#16 Post by GarryRicketson »

Maybe the OP is trying to do some kind of sorcery or cast a witch spell, to confuse and mislead us. :mrgreen:

Post Reply