DateTime Error
Posted
#1
(In Topic #239)
Expert

Can someone else please try this with a DateTime box; if it is a real bug, I'll log it formally.
Code (gambas)
Error returned is : "Type mismatch: Wanted Date , got string instead."
Gambas=3.12.90
OperatingSystem=Linux
Kernel=4.15.0-46-generic
Architecture=x86_64
Distribution=Ubuntu 18.04.2 LTS
Desktop=UBUNTU:GNOME
Theme=Gtk
Language=en_AU.UTF-8
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Administrator

Posted
Expert

Got actual control name wrong…..
DateBox (gb.form)
This control allows to edit a date value. It provides a little button that displays a calendar popup.
Edit: in the 'Chooser' tab.
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Trainee
Also the date must be in us style mm/dd/yyyy. in other case it return the message you have
I can just say the pb is around your use of CDate
:-P
Posted
Regular

Quincunxian said
I had this error and want to confirm that its not just me.
Can someone else please try this with a DateTime box; if it is a real bug, I'll log it formally…
No, it seems to work as expected for me on 3.12.90 (…and on 3.12.2).
The error message: "Type mismatch: Wanted Date , got string instead."
…is a funny one, because I often see this when the error is unrelated to this description (its almost like a fall-back error).
Edit: I'm running 3.12.90 on Lubuntu 18.10 with that new LXQt desktop
Posted
Regular

I got this in the console:
Code
12/31/2018 00:00:00
The date was also 12/31/2018 on the form.
Looks like a bug to me.
It also raises the question, how does one place a Form control on the form at design time if it isn't in one of the panels to the right?
Ced
3.12.2 (Behind the front lines.)
.... and carry a big stick!
Posted
Guru

I am using en_GB.UTF-8 (British)
Stevedee en_GB.UTF-8 (British) - I presume
Quincunxian en_AU.UTF-8 (Austrailia)
Cedron en_US.UTF-8 (USA) - I presume
Sholzy en_US.UTF-8 (USA) - I presume
Just a thought!
Posted
Regular

Posted
Guru

Posted
Regular

cogier said
I did not need either the following worked fine: -
Sure, but that's another story
Posted
Trainee
So the problem can coming from your system too.
:-P
Posted
Regular

cogier said
Thanks, I should have remembered that. Honestly, it's not all that often that I move controls around the form.
Code:
Output:
Code
01/01/2019
12/31/2018 00:00:00
2490589
2490588.16666667
2490588.16666667
Somebody is definitely having trouble getting a date.
(Side note: Could you guys put one of those handy "SELECT ALL" options in the "gb" tag output?
Ced
[System]
Gambas=3.12.2
OperatingSystem=Linux
Kernel=3.13.0-24-generic
Architecture=x86_64
Distribution=Linux Mint 17 Qiana
Desktop=MATE
Theme=Gtk
Language=en_US.UTF-8
.... and carry a big stick!
Posted
Guru

<IMG src="http://www.cogier.com/gambas/date.png">
</IMG>You can change line 10 to: -
Code (gambas)
- d.Value = "01/01/2019"
Same result.
Posted
Regular

Produces:
Code
12/31/2018 20:00:00
2490589
01/01/2019
12/31/2018 20:00:00
12/31/2018
2490588.16666667
12/31/2018 00:00:00
12/31/2018 00:00:00
So I am a bit puzzled. I've always understood internal date representation to be Integer Date + Fraction Of Day Time.
Looks like Str and Val might be problematic.
Ced
From: gambas-master/comp/src/gb.form/.src/Date/DateBox.class
Code (gambas)
- $hButtonBox.Text = GetNullDate()
Code (gambas)
.... and carry a big stick!
Posted
Regular

/lang/cstr - Gambas Documentation
vs
/lang/str - Gambas Documentation
Same with val vs CDate.
So, val and str use localization, CDate and CStr do not.
Hence the observed behavior.
I have not been able to reproduce the OP's original bug.
Ced
.... and carry a big stick!
Posted
Expert

Thanks to all.
I've been keeping a list of things that are either bugs(?) that need to be confirmed or a bit of a wish list.
I'll post in a new thread with a more appropriate title a bit later on.
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Trainee
DateBox1.Value=CDate(CDate("01/01/2019")+1)
Posted
Guru

chescobar said
This work for me:
DateBox1.Value=CDate(CDate("01/01/2019")+1)
It might not have 2 years ago when the post was made
1 guest and 0 members have just viewed this.
