Below SQL statement
SELECT getdate()
go
When I run from SQL Server management studio it gives
"Jul 27 2016 22:00:00.860"
When I run the same from sqsh it gives
"Jul 27 2016 10:00PM"
sqsh uses freetds to connect to SQL server from my linux box. I have a C program which uses freetds and it will work fine when date is retrieved in 24hour format.
I guess there are settings for freetds to get date in required format, can someone please suggest how to accomplish that by freetds settings.
Here's what I just did on my ubuntu linux box:
Type this command at the bash shell: locale My result (shortened): LANG=en_US
Copy locales.conf file to the config directory: sudo cp /usr/share/doc/freetds-common/examples/locales.conf /etc/freetds/
open the /etc/freetds/locales.conf file in an editor
comment out the old date format defined in the locales.conf file (I've used ";" as a comment char), copy the line
Define a date format that you need in the corresponding section of the locales.conf file
[en_US]
;date format = %b %e %Y %I:%M:%S:%z%p
date format = %Y-%m-%d %H:%M:%S
restart your web server process
Now I get from sqsh:
SELECT getdate();
: 2016-08-01 11:37:45
Currently, the default date format returned by FreeTDS is configured in the locales.conf file. See http://www.freetds.org/userguide/locales.htm for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With