Formatting a date in a region/system independent manner

26 views
Skip to first unread message

Guido De Bouver

unread,
May 8, 2023, 1:29:33 PM5/8/23
to Excel-DNA
hello all,

All of my users have different regional settings in Windows and Excel. As a result, when I am trying to format a return value as a timestamp, it fails because the format string ios not recognized on that particular deployment.

So I am doing 
XlCall.Excel(XlCall.xlcFormatNumber, "dd-mmm-yy hh:mm")
However, this fails on German, French or Chinese deployments - eg in French I need to replace the day component with jj ( j from jour )

Also, it seems to me that the WIndows and Excel settings are not always aligned, so this looks like a nightmare to me to find a decent formatting.

Question - is there a date/time formatting that works on all systems, regardless of the regional setting ?? ( realizing that this is not really an ExcelDna question... ).

Thanlks for yoru thoughts.
guido





 

Sergey Zhilyakov

unread,
May 8, 2023, 2:42:15 PM5/8/23
to exce...@googlegroups.com
Hi,

I'm not sure about C API, but COM allows to specify an invariant number format. Use Range.NumberFormat to do so.

Best regards,
Sergey

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/1fc86c5a-00b5-45fe-a5c0-5d7d70b42e79n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages