[Issue] Date 02.04.1945 could not be formatted

Discuss the database features

[Issue] Date 02.04.1945 could not be formatted

Postby coccyx » Wed May 04, 2011 10:13 am

Hi.
I have a OO Base database with Basic. In this there are patients.
last week a new patient with birth on 02.04.1945 could not added to the database.
the following error was shown: Runtime-Error...SQLException...NumberFormatException...for String "yyyy"

i messed a little and checked that the date 02.04.1945 could not be formatted using: Format(BDate, "yyyy-mm-dd") with BDate = "02.04.1945"
other dates like 01.04.1945 or 02.04.1946 are formatted correctly.
i tried with msgbox, Format("02.04.1945", "yyyy-mm-dd") returns "yyyy-mm-dd"...
WHY :(
Last edited by Hagar Delest on Fri May 13, 2011 5:24 pm, edited 1 time in total.
Reason: tagged the thread as Issue (link to a bug report).
Windows 7 Pro 32bit, OOO330m20
coccyx
 
Posts: 7
Joined: Wed May 04, 2011 9:36 am

Re: Date 02.04.1945 could not be formatted

Postby Villeroy » Wed May 04, 2011 11:00 am

Code: Select all   Expand viewCollapse view
I have a OO Base database with Basic.

WIth German locale settings I can enter any of the following into a date field (via table grid, date field or text box)
2.4.45
2.4.1945
2. apr 1945
apr 2 45
1945-4-2
45-4-2
and I always get the exact same date value.

I'd think that your Basic code is not type safe.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29922
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Date 02.04.1945 could not be formatted

Postby coccyx » Thu May 05, 2011 12:32 pm

i forget. the input field is in a extra dialog. i switched the datefield to a textfield with same error.

even if i create a new database, open makoeditor, add line => output
msgbox Format("1945-04-02", "yy-mm-dd") => 1945-04-02
msgbox Format("1946-04-02", "yy-mm-dd") => 46-04-02

msgbox Format("02.04.1945", "yyyy-mm-dd") => yyyy-mm-dd
msgbox Format("02.04.1946", "yyyy-mm-dd") => 1946-04-02
msgbox Format("2. apr 1945", "yyyy-mm-dd") => 2. apr 1945
msgbox Format("2. apr 1946", "yyyy-mm-dd") => 1946-04-02
and so on with other date formats...

Dim tdate AS Date
tdate = "2. apr 1945"
tdate = "02.04.1945"
tdate = "1945-04-02"

returns error "unsupported value or type" for every setting

this was tested on a laptop with OOO320m18, Win7 Pro 32
Windows 7 Pro 32bit, OOO330m20
coccyx
 
Posts: 7
Joined: Wed May 04, 2011 9:36 am

Re: Date 02.04.1945 could not be formatted

Postby r4zoli » Thu May 05, 2011 1:13 pm

The Format() function is not supported in Base, if you use HSQLDB engine see Built-in functions and Stored Procedures.
Other databases use different syntax, in their case use their supported functions.
OOo Base use YYYY-MM-DD ISO format as default.
AOO 4.0 and LibO 4 on Win 8
Hungarian forum co-admin
User avatar
r4zoli
Volunteer
 
Posts: 2882
Joined: Mon Nov 19, 2007 8:23 pm
Location: Budapest, Hungary

Re: Date 02.04.1945 could not be formatted

Postby rudolfo » Thu May 05, 2011 5:25 pm

coccyx wrote:Hi.
I have a OO Base database with Basic. [...]
other dates like 01.04.1945 or 02.04.1946 are formatted correctly.
i tried with msgbox, Format("02.04.1945", "yyyy-mm-dd") returns "yyyy-mm-dd"...

You are a bit unclear about your context. When you are using MsgBox you are running this in the Basic interpreter. R4zoli pointed out that there is a crucial difference: Format as a function in Basic is okay, but not if it is used in a SQL statement. The question is how is your interface to the database? Do you only manipulate the controls of forms holding the current record and later on forcing a form.commit or form.refresh?
Or do you actually build SQL statement strings that you send to the database with getConnection(), createStatement(), execute(), ... ?
In the later case you might have a look at this thread about Date function in SQL query. If you inspect it you will see that it follows somehow Mr.Programmer's approach to use 3 separate fields for year, month and day. But of course in a database table a Date type field of the database backend engine makes the most sense.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
rudolfo
Volunteer
 
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: Date 02.04.1945 could not be formatted

Postby Villeroy » Thu May 05, 2011 7:07 pm

coccyx wrote:i forget. the input field is in a extra dialog. i switched the datefield to a textfield with same error.

even if i create a new database, open makoeditor, add line => output
msgbox Format("1945-04-02", "yy-mm-dd") => 1945-04-02
msgbox Format("1946-04-02", "yy-mm-dd") => 46-04-02

msgbox Format("02.04.1945", "yyyy-mm-dd") => yyyy-mm-dd
msgbox Format("02.04.1946", "yyyy-mm-dd") => 1946-04-02
msgbox Format("2. apr 1945", "yyyy-mm-dd") => 2. apr 1945
msgbox Format("2. apr 1946", "yyyy-mm-dd") => 1946-04-02
and so on with other date formats...

Dim tdate AS Date
tdate = "2. apr 1945"
tdate = "02.04.1945"
tdate = "1945-04-02"

returns error "unsupported value or type" for every setting

this was tested on a laptop with OOO320m18, Win7 Pro 32

Whatever you do with numeric strings in Basic, it will fail when your code runs in another locale context.
Tools>Options>LanguageSettings>Languages>Locale influences how text converts to numbers and dates in the whole office suite including the Basic language. If you want to work with strings rather than date structs, ISO dates are the only viable option. ISO works with any locale and in any context. Database fields can be updated by method setString("1999-12-31"), SQL accepts single quoted '1999-12-31'.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29922
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Date 02.04.1945 could not be formatted

Postby rudolfo » Fri May 06, 2011 1:10 pm

Online Help on Basic wrote:Format Function [Runtime]
Converts a number to a string, and then formats it according to the format that you specify.
Syntax:
Format (Number [, Format As String])

If you have code like MsgBox Format("02.04.1945", "yyyy-mm-dd") you feed the Format function with 2 string parameters. Any compiler would jump right back into your face asking you what you are throwing at him. A script interpreter doesn't do so (unfortunately in some cases), instead it silently converts the string in the first parameter into a number (following its internal rules as described by Villeroy) before it executes Format.
If you don't explicitly tell the Interprete what to do it randomly does one of the following statements:
Code: Select all   Expand viewCollapse view
Format( CDate("02.04.1945"), "yyyy-mm-dd")
Format(CInt("02.04.1945"), "yyyy-mm-dd")
Format(CDbl("02.04.1945"), "yyyy-mm-dd")
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
rudolfo
Volunteer
 
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: Date 02.04.1945 could not be formatted

Postby coccyx » Tue May 10, 2011 10:17 am

Thanks for the answers!
@r4zoli
i use embedded hsqldb
Format is "supported", so i used this. at: http://wiki.services.openoffice.org/wik ... me_Library)
@MrProgrammer
your solution does not fit in my dialog form or rather the users would not check this :)
btw i would use the datepicker in my forms
@rudolfo
i build my own sql string from the dialog inputs
i did not wrote the full declaration in my comment above. but its the same result.
msgbox Format(CDate("02.04.1945"), "yyyy-mm-dd") ==> error
msgbox Format(CInt("02.04.1945"), "yyyy-mm-dd") ==> 1899-12-30
msgbox Format(CDbl("02.04.1945"), "yyyy-mm-dd") ==> 7490-08-26

--> i just dont understand why this special date could not be formatted and all others i tried do.
Windows 7 Pro 32bit, OOO330m20
coccyx
 
Posts: 7
Joined: Wed May 04, 2011 9:36 am

Re: Date 02.04.1945 could not be formatted

Postby rudolfo » Tue May 10, 2011 11:09 am

You say: i build my own sql string from the dialog inputs
But in all the above posts we have never seen a SQL statement!
Seriously if you execute msgbox Format(CDate("02.04.1945"), "yyyy-mm-dd") this is only seen by the Basic interpreter but not by the parser of the database engine. You can't verify or check Runtime-Error...SQLExceptions with this.
You surely have something like
Code: Select all   Expand viewCollapse view
sqlstring = "INSERT INTO your_table (date_col,more_info) VALUES ('" _
                & Format("02.04.1945", "yyyy-mm-dd") & "','arbirtrary text')"
connection.createStatement(sqlstring)

Simply paste this part of your code in your next post. This will bring us a big step further.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
rudolfo
Volunteer
 
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: Date 02.04.1945 could not be formatted

Postby coccyx » Tue May 10, 2011 4:09 pm

see my first post, the sql (createStatement) throws an exception, so i check which part of it was wrong. this was the return of Format(...) which returns "yyyy-mm-dd" instead of "1945-04-02" ONLY with this special date, all others dates that have been put in the database worked fine. so i tested some dates and the Format() with
Code: Select all   Expand viewCollapse view
msgbox Format(CDate("02.04.1945"), "yyyy-mm-dd")

to get the returning values.
the sqlstring normally works fine. the only problem is this special date and the Format(). maybe this is a bug in OO, i dont know...

heres the sql code...
Code: Select all   Expand viewCollapse view
If DlgPatient.getControl("PatGeschlecht0").State = True Then Geschlecht = "männlich" Else Geschlecht = "weiblich"
If DlgPatient.getControl("PatVart0").State = True Then Vart = "GKV" Else Vart = "PKV"

Sql2 = "UPDATE ""Patientendaten"" SET ""Nachname"" = '" + DlgPatient.getControl("PatName").Text + "', " &_
       """Vorname"" = '" + DlgPatient.getControl("PatVorname").Text + "', " &_
       """Geschlecht"" = '" + Geschlecht + "', " &_
       """Geburtstag"" = '" + Format(DlgPatient.getControl("PatGeburtstag").Text, "yyyy-mm-dd")) + "', " &_
       """Hausarzt"" = '" + DlgPatient.getControl("PatArzt").Text + "', " &_
       """Krankenkasse"" = '" + DlgPatient.getControl("PatKasse").Text + "', " &_
       """Telefon"" = '" + DlgPatient.getControl("PatTelefon").Text + "', " &_
       """Email"" = '" + DlgPatient.getControl("PatEmail").Text + "', " &_
       """Adresse"" = '" + DlgPatient.getControl("PatAdresse").Text + "', " &_
       """Postleitzahl"" = '" + DlgPatient.getControl("PatPlz").Text + "', " &_
       """Ort"" = '" + DlgPatient.getControl("PatOrt").Text + "', " &_
       """Anmerkung"" = '" + DlgPatient.getControl("PatAnmerkungen").Text + "', " &_
       """Vart"" = '" + Vart + "', " &_
       """Vnummer"" = '" + DlgPatient.getControl("PatVnummer").Text + "' " &_
       "WHERE ""PatientID"" = " + VarPatient 
datenbank.executeUpdate(Sql2)
same for Insert statements
Windows 7 Pro 32bit, OOO330m20
coccyx
 
Posts: 7
Joined: Wed May 04, 2011 9:36 am

Re: Date 02.04.1945 could not be formatted

Postby coccyx » Tue May 10, 2011 5:39 pm

so i testes with various machines, all 32 bit, german locale settings

PC: Win 7 Pro SP1 German OOO330m20 => error
Laptop: Win 7 Home Premium SP1 OOO320m18 => error
VMware: Win XP Pro SP3 OOO330m20 => works
Laptop: Win XP Pro SP3 German OOO320m18 => works

seems to be platform dependent
Windows 7 Pro 32bit, OOO330m20
coccyx
 
Posts: 7
Joined: Wed May 04, 2011 9:36 am

Re: Date 02.04.1945 could not be formatted

Postby Villeroy » Tue May 10, 2011 5:51 pm

Code: Select all   Expand viewCollapse view
....getControl("PatGeburtstag").Text

"Geburtstag" means "birth day" and might be a date value.

The form control's text is meaningless, particularly when the record is not saved. Use the 8-digit integer value of a date control or struct com.sun.star.util.Date from the underlying record set. The integer is always YYYYMMDD as in today's 20110510.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29922
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Date 02.04.1945 could not be formatted

Postby rudolfo » Tue May 10, 2011 7:12 pm

coccyx wrote:i use embedded hsqldb
Format is "supported", so i used this. at: http://wiki.services.openoffice.org/wik ... me_Library)

Actually this is a missunderstanding. Format() is not supported in HSQLDB. The fact that the database is embedded into a Base document doesn't mean that the hsqldb incorporates now the programming features of the BASIC language that can be used within a Base document. In fact it is the other way round. Many of the features of HSQLDB (Triggers, ...) can not be used because the database is embedded into a Base document.

Your code
Code: Select all   Expand viewCollapse view
Sql2 = "UPDATE ""Patientendaten"" SET ....
   " + Format(DlgPatient.getControl("PatGeburtstag").Text, "yyyy-mm-dd") + "...."

is executed by the BASIC interpreter. The SQL parser of the embedded database sees only the concatenated string as you could see it when you insert a MsgBox Sql2 right before the .executeUpdate(sql2).

I strongly recommend to read Roberto Benitez' document (pdf)about Base Programming. Particularly the sections about prepared Statements and parameter binding.
With string concatenation in Basic as you are using it now, you won't be able to insert a name with a apostrophe like O'Connor:
Code: Select all   Expand viewCollapse view
stmt = datenbank.prepareStatement("UPDATE ""Patientendaten"" SET ""Nachname"" = ?, ""Vorname"" = ?, ..." _
        & ... & "WHERE ""PatientID"" = ?")
stmt.setString(1, DlgPatient.getControl("PatName").Text)
stmt.setString(2, DlgPatient.getControl("PatVorname").Text)
:
stmt.setInt(15, VarPatient)
stmt.executeUpdate()
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
rudolfo
Volunteer
 
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: Date 02.04.1945 could not be formatted

Postby Villeroy » Tue May 10, 2011 8:45 pm

Trying to convert date-times in stupid Basic. Converts between Basic dates, UNO dates, double dates and 8-digit date/time integers for date/time form controls. No fractions of seconds, please. We're Basic.
Code: Select all   Expand viewCollapse view
sub test_ConvertDateTime
Dim ds$
REM cheap decimal separator:
ds = mid(PI(),2,1)
Dim udt
dim s$,dt as date,d#,l&,t%
dt= cDate(-1.4)
'print cdatetoiso(dt)'ConvertDateTime(s, "ISO")
'exit sub

s = "1999-12-31 23:45:59"& ds & "43"
udt = ConvertDateTime(s, "unostruct")
print ConvertDateTime(udt, "iso")

dim x#,y&,z#
x = cDbl(Now())

udt = ConvertDateTime(x, "unostruct")
print ConvertDateTime(udt, "iso")
print ConvertDateTime(udt, "double")
print ConvertDateTime(udt, "basic")
end sub

Function ConvertDateTime(byval vIN, byval sOUT$)
'calls: getDateTimeFromStruct
REM Basic can not handle fractions of seconds
dim basDT as Date, sD$, sT$
select case vartype(vIN)
case 2 to 8
   basDT = cDate(vIN)
case else
   basDT = getDateTimeFromStruct(vIN)
end select
on error goto nullErr:
REM CDateToISO(basDt) fails with date+time, so we concatenate
REM get the 8 digits of the date and 8 digits of the time:
sD = format(year(basDT),"0000")& format(month(basDT),"00")& format(day(basDT),"00")
sT = format(hour(basDT),"00")& format(minute(basDT),"00")& format(second(basDT),"00")&"00"
select case uCase(sOUT)
case "INTDATE"
   '8-digit integer 19991231 as used in date controls
   ConvertDateTime = cLng(sD)
case "INTTIME"
   '8-digit integer 23455900 as used in time controls
   ConvertDateTime = cLng(sT)
case "DOUBLE"
   ' formattable number as in spreadsheets
   REM CAUTION: This one always assumes 1899-12-30 00:00:00 as zero time
   ConvertDateTime = cDbl(basDt)
case "BASIC"
   ' variant of subtype Date for basic language only:
   ConvertDateTime = basDT
case "STRING"
   ' localized string such as 12/31/1999 11:45:59 PM
   ConvertDateTime = cStr(basDT)
case "ISO"
   ' ISO string
   ConvertDateTime = left(sD,4)&"-"& mid(sD,5,2)&"-"& right(sD,2)&" "& left(sT,2)&":"& mid(sT,3,2)&":"& mid(sT,5,2)
case "UNOSTRUCT"
dim unoDT as new com.sun.star.util.DateTime
   unoDT.Year = Year(basDT)
   unoDT.Month = Month(basDT)
   unoDT.Day = Day(basDT)
   unoDT.Hours = Hour(basDT)
   unoDT.Minutes = Minute(basDT)
   unoDT.Seconds = Second(basDT)
   ConvertDateTime = unoDT
case else
   ConvertDateTime = Null
   exit function
end select

exit function
nullErr:
   ConvertDateTime = Null
End Function
Function getDateTimeFromStruct(vUnoStruct)
   Dim basD as Date, basT as Date, basDT as Date, iCount%
   on error goto errCount
      basD = DateSerial(vUnoStruct.Year, vUnoStruct.Month, vUnoStruct.Day)
      basT = TimeSerial(vUnoStruct.Hours, vUnoStruct.Minutes, vUnoStruct.Seconds)
      basDT = basD + basT
   if iCount <2 then
      getDateTimeFromStruct = basDT
   else
      getDateTimeFromStruct = Null
   endif
exit function
errCount:
   iCount = iCount +1
   resume next
End Function

Resulting bug report: [Bug 117989] Basic functions Day, Hour,Minute return wrong results for dates <1900-1-1
Anything is better than Basic.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29922
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Date 02.04.1945 could not be formatted

Postby RPG » Tue May 10, 2011 10:52 pm

Hello

It seems that basic does have a lot of errors but also some hidden stuff what can help. I can update date field and timestamp fields with. I think that OOo is changing all the values when it knows what the source values is and knows what the result must be.


Code: Select all   Expand viewCollapse view
Sub Main
oForm=thiscomponent.drawpage.forms.getbyName("Formulier")

oForm.getbyname("Begin").BoundField.updatedouble(date) ' This is defined as a date field in the database.
oForm.getbyname("Begin").commit
oForm.getbyname("tijd").BoundField.updatedouble(now) 'This is defined as a timestamp in the database.
oForm.getbyname("tijd").commit
End Sub


For a timestamp field you can use two control one displaying date and the other the time but also you can use one control : a formatted control. In the controls I see no fractions of seconds. I believe they are stored in the database but I have not test them.

Romke
LibreOffice 6.3.3.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2204
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Date 02.04.1945 could not be formatted

Postby coccyx » Wed May 11, 2011 7:43 am

@rudolfo
i know that my style of programming is not the best, but the main problem is not the way i put strings together... but i will check it for further projects :)
@villeroy
with your code the error is the same for s = "02.04.1945...
Windows 7 Pro 32bit, OOO330m20
coccyx
 
Posts: 7
Joined: Wed May 04, 2011 9:36 am

Re: Date 02.04.1945 could not be formatted

Postby Villeroy » Wed May 11, 2011 9:56 am

coccyx wrote:@villeroy
with your code the error is the same for s = "02.04.1945...

I could reproduce the problem with LibreOffice on Windows 7, but not on my Linux machines.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29922
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Date 02.04.1945 could not be formatted

Postby RoryOF » Wed May 11, 2011 10:27 am

coccyx's report on 20110511 1636 indicates that it seems to be a Win 7 problem. Villeroy's last report also indicates this.
Apache OpenOffice 4.1.10 on Xubuntu 20.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 32709
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Date 02.04.1945 could not be formatted

Postby Villeroy » Wed May 11, 2011 12:01 pm

Python provides a rock solid and very well established programming language with time zones, locale settings, hundredths of seconds, even leap seconds are taken into condideration:
http://docs.python.org/release/2.6.6/li ... etime.html
http://docs.python.org/release/2.6.6/library/time.html
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29922
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Date 02.04.1945 could not be formatted

Postby rudolfo » Wed May 11, 2011 2:48 pm

Maybe it is worth a try to change the way how you retrieve the data from the control and use a similar method that Romke suggested: Instead of DlgPatient.getControl("PatGeburtstag").Text use:
DlgPatient.getControl("PatGeburtstag").BoundField.getString()
I have tested this with a Date Control bound to a Datetime field of a MySQL database table (LibO 3.3.2 on Win2k)
Code: Select all   Expand viewCollapse view
.Text --------------------> 19450402
.BoundField.getString() --> 1945-04-02 23:00:00

The format of the Date control is "Standard (Short)" probably using the german locale settings of the OS and shows the date in the field as 02.04.45. I would assume that .BoundField.getString() returns 1945-04-02 if the associated Date field in the table is of type Date and not Datetime. So it should be good for your purposes. If you directly concatenate the returned string value from .BoundField.getString() into your SQL statement all conversion (if any happens) is done inside UNO object and Basic is out of the game and won't be able to mess things.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
rudolfo
Volunteer
 
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: Date 02.04.1945 could not be formatted

Postby Villeroy » Wed May 11, 2011 3:59 pm

DateCtrl.Date => int 19450402
Ctrl.BoundField.getDate() => int struct c.s.s.util.Date
Form.getDate(ColumnIndex) => struct c.s.s.util.Date
Form.Columns.getByIndex(ColumnIndex).getDate() => struct c.s.s.util.Date
Form.Columns.getByName(ColumnName).getDate() => struct c.s.s.util.Date

http://api.openoffice.org/docs/common/r ... /Date.html
Last edited by Villeroy on Wed May 11, 2011 5:21 pm, edited 1 time in total.
Reason: Made corrections suggested by Romke
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29922
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Date 02.04.1945 could not be formatted

Postby RPG » Wed May 11, 2011 5:07 pm

Hello

When you are working with a date control and you ask a value with: oControl.date then you get a long integer with a iso format.
When you ask: Form.Columns.getByIndex(ColumnIndex).getDate() then you get an unostruct and not a long integer.

Romke
LibreOffice 6.3.3.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2204
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Date 02.04.1945 could not be formatted

Postby coccyx » Fri May 13, 2011 10:38 am

i tested to convert Datatypes: Integer -> Date -> String -> Date. and the only error was date "2.4.1945" with i=16529. so, i submitted a bug report... http://openoffice.org/bugzilla/show_bug.cgi?id=118010
pseudocode:
Code: Select all   Expand viewCollapse view
for i=0 to 41000
   date = i
   text = date
   date = text
Windows 7 Pro 32bit, OOO330m20
coccyx
 
Posts: 7
Joined: Wed May 04, 2011 9:36 am


Return to Base

Who is online

Users browsing this forum: No registered users and 4 guests