Forum > Win32/64

DateTime

(1/2) > >>

seghele0:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ilename := 'Wiezen-' + FormatDateTime('ddmmyyyy',Date)+ '.xlsx';workbook.WriteToFile(filename, sfOOXML, true);    
Sorry to bother you again. The above code works perfectly, but I would like to add the time.

Following code doesn't work:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---filename := 'Wiezen-' + FormatDateTime('ddmmyyyy'+'hh:mm', Date) + '.xlsx'; Please help.

CCRDude:
The ":" is not allowed as part of the filename e.g. on Windows. It's only allowed in second place of a complete path, right after the drive letter (on Windows).

Just pick a different separator, like a dash?

BobDog:

This seems to work.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- Uses sysutils; Begin  Writeln ('Date and Time : ',FormatDateTime('c',now));  readln;End.

wp:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---filename := 'Wiezen-' + FormatDateTime('ddmmyyyy-hhmm', Now) + '.xlsx';
As already noted, don't use a colon as time separator, it is forbidden (at least on Windows, not sure about Linux - on Windows it is reserved for the separator after the disk drive, e.g. c:\windows...).

And when you want to store the time, use the function Now to retrieve the current complete time - Date would only return the date part, and the time part would always be shown as '00:00' in the filename.

CCRDude:

--- Quote from: BobDog on September 22, 2021, 05:02:13 pm ---
This seems to work.

--- End quote ---
Because the string is not used as a filename.

Navigation

[0] Message Index

[#] Next page

Go to full version