BASIC+Calc : How to convert string to date
d = "25" : m = "10" : y = "2019"
oCell = oSheet.GetCellByPosition(0, 0) : oCell.[How to store m & "/" & d & "/" & y in this cell with date format?]
First time here? Check out the FAQ!
d = "25" : m = "10" : y = "2019"
oCell = oSheet.GetCellByPosition(0, 0) : oCell.[How to store m & "/" & d & "/" & y in this cell with date format?]
Edited to account for the M/D/Y format mentioned in the question
dim oCell as object, oLocale as object, nFmtId as Long
oCell = ThisComponent.CurrentController.ActiveSheet.GetCellByPosition(0, 0)
oLocale = ThisComponent.NumberFormats.getByKey(oCell.NumberFormat).Locale
nFmtId = ThisComponent.NumberFormats.queryKey("MM/DD/YYYY", oLocale, False)
if nFmtId = -1 then _
nFmtId = ThisComponent.NumberFormats.addNew("MM/DD/YYYY", oLocale)
oCell.NumberFormat = nFmtId
oCell.Value = DateSerial(2019, 10, 25)
Thank you so much for your explanation and your assistance.
Asked: 2019-10-14 05:16:32 +0100
Seen: 335 times
Last updated: Oct 14 '19
Can't save LibreOffice Basic Macro in .xls file [closed]
VBA support - "selection.copy" not working in LO3.5 [closed]
How do I export a chart in an image format from LibreOffice Calc? [closed]
Are there plans for a "papercut" project for libreoffice [closed]
Is it normal for Calc goal seek to take very long? [closed]
Please refine "Search" in Calc - implement functions in Gnumeric [closed]
LibreOffice Calc will not link to external data via internet [closed]
Is there a LibreOffice .odt, .ods viewer for Android? [closed]