How can i fetch a date from the database and rename a file with that date(how to get a value from database in a variable in batch file).
Much depends on the format of the DB. Should we guess?
=====================================
Helping others achieve escape felicityM2
most database-management apps have a version of "export" (as in "to asciifile") OR a text-file reporting capability. You need to establish the record-selection criteria then export or "list-to-text" the date field from the record or records that qualify. your batch can then pick them up from the text file.
M2 i want to rename the file in yyyymmdd format.
nbrane i am not sure how to implement your solution.
M2 when i query the database i get the date in following format:
3/10/2010 1:05:32 PMBut when i spool the output from the batch file i get the file as follows:
SF_DATE ---------------------
10-MAR-10
> How can i fetch a date from the database
> and rename a file with that date(how to get
> a value from database in a variable in batch file).
>There's 2 ways to handle this:
- go to the database (whatever the tool is) and find a feature that allows writing to a file (if it exists). Some DB-query languages have such a tool, others have not. Ask an application-programmer that works on writing software for the application which uses that database.
- The other way is my favorite, and that is the other way round. Use the OS command line, to query something on the database (the date, for example), and redirect output to a file (or to the command line) and work with that, in a OS script kind of matter. You will need a non-graphic (command line) interface program with your database, for this to work ... or, be lucky that you have a GUI which allows all ouput to be forwarded to a file.What is the database, what is the tool used to access the DB ?
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |