Squirrel sql date format issue - squirrel-sql

I would like to change the date time format that is being displayed in squirrel SQL client from yyyy-mm-yyyy hh:mm:ss.mi to dd-mm-yyyy hh:mm:ss.
Could not find these in global settings
Version I am using is : 4.5.0
Thanks

Related

MySQL date and datetime formats unrecognised by Data Studio

I've linked Google data studio with a MySQL database using the standard connector. Almost everything works fine except for date and datetime fields.
I have these 2 fields in phpmyadmin (field name, field type, output):
Validated_date datetime 2017-09-27 12:31:04
Expiration_date date 2017-12-24
In Data Studio I've set these types, but none of them are recognised:
Validated_date Date Hour (YYYYMMDDHH)
Expiration_date Date (YYYYMMDD)
I tried to format the field with date_format in my SELECT:
DATE_FORMAT(p.Expiration_date, '%Y%m%d') AS "Expiration Date"
I even tried other date_formats but they're never recognised as dates in Data Studio:
DATE_FORMAT(p.Expiration_date, '%Y/%m/%d') AS "Expiration Date"
DATE_FORMAT(p.Expiration_date, '%Y-%m-%d') AS "Expiration Date"
Any idea?
I had the same issue. My approach to solve this is to modify the date format within Google Data Studio by creating a new dimension, reformatting the mySQL Datetime into the desired format.
In your example you use DATE_FORMAT. I wonder if you apply this in Data Studio (which does not know DATE_FORMAT) or in mySQL?. If you do it in data studio and leave your mySQL/phpmyadmin untouched you can use this:
TODATE(your-date-field, 'DEFAULT_DASH', '%Y%m%d')
This will take the date format YYYY-MM-DD with optional time in HH:ii:ss and reformat it into YYYYMMDD which works with data studio.
I've never tried directly with Data Studio but when I extract datetime fields from mySQL to use in BigQuery I use:
CONVERT(DATETIME2(0), [DATETIME_FIELD])
This removed any milliseconds which generally cause problems and convert it to a recognisable datetime format for Google
I have used the follow formule and working for me:
TODATE(yor-field-from-mysql, '%Y-%m-%dT%H:%M:%S', "%Y%m%d%H%M")Then I choose ***YYYYMMDDhhmm*** format in DataStudio. I hope it helps.
Edit: In this case, date came from javascript using moment.js
I had the same issue. For me, the only solution was create a formula this way:
CONCAT(SUBSTR(field, 1, 4), SUBSTR(field, 6, 2), SUBSTR(field, 9, 2))
and use this as AAAAMMDD format

Change Date Format in SQL Server 2008

I have a table where users used to enter random date formats like
dd/MM/Year or MM/dd/Year.
But I want to update all those dates to this format Year/MM/dd
I have made a cursor and changed data by CHAR INDEX and sub string..
but is there any easy way to change the date format to the one i want ?
and also how can I make my default database date format = Year/mm/dd
only database not server?
You can convert it into different styles.
for example:
select convert(varchar(15),getdate(),103)
will give today's date in dd/mm/yyyy.
Full list of converting styles supported by MSSQL is here

Is there any similar function as of FORMAT in SQL Server 2008 or 2010

AS MSDN :
FORMAT Returns a value formatted with the specified format and
optional culture in SQL Server 2012. Use the FORMAT function for
locale-aware formatting of date/time and number values as strings.
Is this or any similar function available in 2008 or R2 or 2010 for formatting purpose?
Update:
I don't know too. But I heard Microsoft released some SQL Version code-named 'Denali' in year 2010 as Sql 2010 or 2011
There is no explicit FORMAT function, but if you are converting a datatype to a string (such as date etc) the CONVERT function supports different formats that can be applied by specifying the correct code.
The codes are detailed here:
CAST and CONVERT
e.g. if you wanted to format a datetime as a string with the format "YYYY-MM-DD HH:MI:SS", you could use the following:
SELECT CONVERT(VARCHAR(19), GETDATE(), 120)
Where the code 120 is the style.
It works for more than just dates too, I've used it with varbinary and XML data too.

How to make the default date format dd/mm/yyyy in SQL Server 2008?

I have an Excel file that contains a column full of dates in the dd/mm/yyyy format. When I try to import it using openrowset, it said that there was a datatype mismatch. I have a table where the date is defined as type date. Now, I know that the default date format in SQL Server is yyyy-mm-dd. How can I avoid this conflict? Is there a way I can make the default date type be dd/mm/yyyy? I need to do this import operation everyday and it has to be automated and so I cannot afford it to fail in between. I tried using sp_addlanguage to make it British as the default date type is dd/mm/yyyy there, but it didn't work :(. I'm using SQL Server 2008 and Windows 7, if that is of any help. Please help me out! Thanks!
You could CONVERT the incoming data before you insert it. So, in the openrowset statement, where you select the field, you could surround it with a CONVERT statement. Here's an example:
print convert(date,'19/07/2010',103)
This is a UK style date, but if you run it you can see that it's converted it to SQL-friendly format.

How to see this format hh:mm from hh:mm:ss in SQL Server 2008 query?

How to see this format hh:mm from hh:mm:ss in SQL Server 2008 query ?
There's no direct, built-in functionality for this.
Assuming you have a DATETIME or TIME column in SQL Server, you need to hack it like this:
SELECT
SUBSTRING(CONVERT(VARCHAR(20), YourDateTimeColumn, 108), 1, 5)
The CONVERT statement with style = 108 will convert your date to hh:mm:ss and then you just chop off the last three characters.
Things like this really shouldn't be done in the database - that's purely presentation logic, and it belongs in the UI app.