Comprehensive Guide to gsqlcmd Functions
Functions enable you to populate parameter values defined in the /set and /add options.
For instance, you can download historical prices from Yahoo Finance or MSN Money into files named AAPL.json or FB.json, where the file names include stock symbols.
You can add a symbol and the loaded time to your output data using functions like this:
gsqlcmd convert src\*.JSON csv\*.CSV /add=Symbol=FileNameWithoutExtension();LoadDate=FileDateTime()
Several functions rely on NYSE trade time, which corresponds to actual EST time during NYSE trading hours (9:30 AM - 4:00 PM) and EST 4:00 PM of the last trading day after hours.
Other functions use time parsed from file names. You can create these time components using the stamp mode.
The FileText()
function (without a file name) returns the content of the current input file or web request. You can use this to save the content in a database with the /set option, like so: /set=content=FileText()
.
List of Functions
Function | Meaning |
---|---|
UtcNow() | Current UTC date and time |
UtcDateTime() | Current UTC date and time |
UtcDate() | Current UTC date |
UtcTime() | Current UTC time |
Now() | Current date and time |
DateTime() | Current date and time |
Date() | Current date |
Time() | Current time |
NyseDateTime() | NYSE trade date and time |
NyseDate() | NYSE trade date |
NyseTime() | NYSE trade time |
FileDateTime([<File>]) | File date and time |
FileDateTimeUtc([<File>]) | File UTC date and time |
FileDateTimeNyse([<File>]) | File date and time as NYSE trade date and time |
FileDate([<File>]) | File date |
FileDateUtc([<File>]) | File UTC date |
FileDateNyse([<File>]) | File date as NYSE trade date |
FileTime([<File>]) | File time |
FileTimeUtc([<File>]) | File UTC time |
FileTimeNyse([<File>]) | File time as NYSE trade time |
FileName([<File>]) | File name |
FileNameOnly([<File>]) | File name without extension |
FileNameWithoutExtension([<File>]) | File name without extension |
FileNameWithoutPage([<File>]) | Input file name without extension and page |
FilePage([<File>]) | Input file page (e.g., 2 for "AAPL-02.htm") |
FileText([<File>]) | File text |
FileNameDateTime(<File>) | Date and time parsed from an input file name * |
FileNameDate(<File>) | Date parsed from an input file name * |
FileNameTime(<File>) | Time parsed from an input file name * |
* Supported formats for dates and times in file names:
The value after the first hyphen | The value at the name end |
---|---|
*-yyyyMMddHHmmss*.* | *yyyyMMddHHmmss.* |
*-yyyyMMdd-HHmmss*.* | *yyyyMMdd-HHmmss.* |
*-yyyyMMddTHHmmss*.* | *yyyyMMddTHHmmss.* |
*-yyyy-MM-dd*.* | *yyyy-MM-dd.* |
*-yyyyMMdd*.* | *yyyyMMdd.* |
*-HHmmss*.* | *HHmmss.* |