Ask Your Question
0

BASIC+Calc : How to convert string to date

asked 2019-10-14 05:16:32 +0100

lonk gravatar image
d = "25" : m = "10" : y = "2019"
oCell = oSheet.GetCellByPosition(0, 0) : oCell.[How to store m & "/" & d & "/" & y in this cell with date format?]
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2019-10-14 10:10:36 +0100

updated 2019-10-14 10:54:23 +0100

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)
edit flag offensive delete link more

Comments

@Mike Kaganski

Thank you so much for your explanation and your assistance.

lonk gravatar imagelonk ( 2019-10-14 11:30:30 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-10-14 05:16:32 +0100

Seen: 41 times

Last updated: Oct 14