Error command DATE

Here you can discuss every aspect of Debian. Note: not for support requests!

Error command DATE

Postby elkergb » 2019-05-23 23: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?
Thank you very much in advance.
elkergb
 
Posts: 2
Joined: 2019-05-23 23:39

Re: Error command DATE

Postby GarryRicketson » 2019-05-24 01:50

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: 5877
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Error command DATE

Postby GarryRicketson » 2019-05-24 02:04

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
User avatar
GarryRicketson
 
Posts: 5877
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Error command DATE

Postby trinidad » 2019-05-24 12:04

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.
trinidad
 
Posts: 76
Joined: 2016-08-04 14:58

Re: Error command DATE

Postby GarryRicketson » 2019-05-24 12:44

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.
User avatar
GarryRicketson
 
Posts: 5877
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Error command DATE

Postby elkergb » 2019-05-27 20:47

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 4378 times
print_ubuntu.png
print_ubuntu.png (22.69 KiB) Viewed 4378 times
print_debian.png
print_debian.png (18.22 KiB) Viewed 4378 times
elkergb
 
Posts: 2
Joined: 2019-05-23 23:39

Re: Error command DATE

Postby GarryRicketson » 2019-05-27 21:55

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
?
User avatar
GarryRicketson
 
Posts: 5877
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Error command DATE

Postby trinidad » 2019-05-31 12:53

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.
trinidad
 
Posts: 76
Joined: 2016-08-04 14:58

Re: Error command DATE

Postby GarryRicketson » 2019-05-31 13:17

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
GarryRicketson
 
Posts: 5877
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Error command DATE

Postby None1975 » 2019-05-31 13:27

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 10.1 Buster / WM: Xmonad
Debian Wiki | DontBreakDebian, My config files in github
User avatar
None1975
 
Posts: 944
Joined: 2015-11-29 18:23
Location: Lithuania, Vilnius

Re: Error command DATE

Postby trinidad » 2019-05-31 14:06

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: 76
Joined: 2016-08-04 14:58

Re: Error command DATE

Postby trinidad » 2019-06-01 12:17

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.
trinidad
 
Posts: 76
Joined: 2016-08-04 14:58

Re: Error command DATE

Postby Head_on_a_Stick » 2019-06-01 13:53

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.
Don't break DebianHow to report bugs

SharpBang GNU/Linux — a pre-configured Openbox/Tint2 desktop running on Debian stable
User avatar
Head_on_a_Stick
 
Posts: 10600
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Error command DATE

Postby Bloom » 2019-06-01 14:11

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
User avatar
Bloom
 
Posts: 193
Joined: 2017-11-11 12:23

Re: Error command DATE

Postby trinidad » 2019-06-01 14:33

@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.
trinidad
 
Posts: 76
Joined: 2016-08-04 14:58

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable