Hi
I am trying to write a program to get a list of log files and sort by the .DateLastModified then open the most recent and search for text, then the next oldest file, etc.
I thought it would be easiest to insert into a MS SQL table and then query the table and ORDER BY Modified DESC.
I am having trouble with the date and time formats.
I have this SQL command
commandtext = "INSERT INTO tblPrintLogs (Logfile,Modified) VALUES ('" & fileName & "',CONVERT(datetime, '" & file.DateLastModified & "', 103))"
This results in a command
INSERT INTO tblPrintLogs (Logfile,Modified) VALUES ('print.dbg',CONVERT(datetime, '21/08/2009 1:32:49 p.m.', 103))
Which has problems with the p.m.
So
-Is there an easy way to sort files by .DateLastModified so I don't need the SQL table?
-Is there a way to convert the date time easily in VBScript so that it will insert into the DB as datetime? NZ to USA date. AM/PM to 24 hour.
-Is there an easy way to remove the fullstops from the p.m. so that the SQL CONVERT will work? Do I need to remove these from the string, check if AM or PM and append new text back onto the string?
-Are there any other ideas?
Thanks
I am trying to write a program to get a list of log files and sort by the .DateLastModified then open the most recent and search for text, then the next oldest file, etc.
I thought it would be easiest to insert into a MS SQL table and then query the table and ORDER BY Modified DESC.
I am having trouble with the date and time formats.
I have this SQL command
commandtext = "INSERT INTO tblPrintLogs (Logfile,Modified) VALUES ('" & fileName & "',CONVERT(datetime, '" & file.DateLastModified & "', 103))"
This results in a command
INSERT INTO tblPrintLogs (Logfile,Modified) VALUES ('print.dbg',CONVERT(datetime, '21/08/2009 1:32:49 p.m.', 103))
Which has problems with the p.m.
So
-Is there an easy way to sort files by .DateLastModified so I don't need the SQL table?
-Is there a way to convert the date time easily in VBScript so that it will insert into the DB as datetime? NZ to USA date. AM/PM to 24 hour.
-Is there an easy way to remove the fullstops from the p.m. so that the SQL CONVERT will work? Do I need to remove these from the string, check if AM or PM and append new text back onto the string?
-Are there any other ideas?
Thanks