On 02/08/2013 11:15 PM, Joel Madero wrote:

Hi Joel,

I have some vague recollection that the Date function in Calc (i.e. the
one used when entering manually) and the Date function in Basic are not
the same...

You could always see whether any of the methods used in this Java
snippet, taken from the API documentation, are of any use :

SpreadsheetDocHelper.java


/** Writes a date with standard date format into a spreadsheet.
        @param xSheet  The XSpreadsheet interface of the spreadsheet.
        @param aCellName  The address of the cell (or a named range).
        @param nDay  The day of the date.
        @param nMonth  The month of the date.
        @param nYear  The year of the date. */
    public void setDate(
            com.sun.star.sheet.XSpreadsheet xSheet,
            String aCellName,
            int nDay, int nMonth, int nYear ) throws RuntimeException,
Exception
    {
        // Set the date value.
        com.sun.star.table.XCell xCell = xSheet.getCellRangeByName(
aCellName ).getCellByPosition( 0, 0 );
        String aDateStr = nMonth + "/" + nDay + "/" + nYear;
        xCell.setFormula( aDateStr );

My understanding of this snippet is that you have to specifically
convert the separated values of your date string to INT, and then
introduce the separators so that once inserted altogether in a cell,
Calc will interpret it as a date, and format it according to your locale.




Alex


-- 
For unsubscribe instructions e-mail to: users+h...@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Reply via email to