I have a database in SQL Server that also has a related tabular database in Analysis Server. One of the tables has columns of type date in SQL Server:
If I run a SQL select in SQL Server select * from app_dates , I get the dates:
But if I run the equivalent in DAX evaluate app_dates I get date/time values instead of dates:
The problem is that my program detects automatically the types, and the type that Analysis Services returns is date/time instead of date.
How to tell Analysis Services that the column type should be date ?
Change the data type and data format of that column in your SSAS model. You can do this by viewing the properties of the column. I have an example below how to get the MM/DD/yyyy format you want without the time.
https://learn.microsoft.com/en-us/analysis-services/tabular-models/column-properties-ssas-tabular?view=asallproducts-allversions
Related
I have a project that needs to work on both Oracle and SQL Server. It currently runs on Oracle, and my job is to make queries compatible for Oracle and SQL Server.
The Oracle database has a table with a column called study_date which has DATE type. So in Java code, I create parameter like this:
MapSqlParameterSource parameters = new MapSqlParameterSource();
Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("America/New_York"));
calendar.setTimeInMillis(event.getTime()); //returns long value of time
parameters.addValue("study_date", calendar);
...
...
return parameters;
This works and insert a row with given time. However, if I run the same code with SQL Server, it doesn't work. I found there are many date types in SQL Server: https://learn.microsoft.com/en-us/sql/t-sql/data-types/date-and-time-types?view=sql-server-ver15, but none of the types work with Calendar object in java.
I was able to insert a row by creating Timestamp using Calendar object I created. It works, but that means I have to write two different sets of code for Oracle and SQL Server. I can, but I am looking for the best way to handle this.
We are migrating SQL Server system into Oracle implementation.
The application design date type:
SQL Server is achieved with DATETIME datatype EMPLOYEE(EMPLOYEE_HIRED DATETIME). Some of the columns contains time component as well till seconds.
Oracle is achieved with DATE datatype EMPLOYEE(EMPLOYEE_HIRED DATE). As we know, oracle date can hold time component as well
While migrating data from SQL Server to Oracle using SSIS, The system is defaulting it to TIMESTAMP datatype of oracle. Can this be defaulted to DATE?
There are around 1000+ such columns.
Do we need to address them manually through data conversion tool box? Can this be automated?
I Used SELECT TO_CHAR(sysDate,'dy') FROM DUAL In oracle and I want to get the same output in SQL Server. I tried several ways and I want to know the date style value for this format.
CONVERT(VARCHAR(max),'2017-03-06T00:00:00.000',<DateStyle>)
I have deployed an SQL Server 2012 on a Windows Server en-us.
Now my dates on Analysis services are in this format MM/dd/yyyy. the company is not American, therefore I would like to change it to yyyy-MM-dd.
Everything seems to be properly configured, however, SSAS is refusing to output the dates in the desired format.
Query on SQL Database engine
Windows Server Regional Settings
an easy and fast way is to create a computed column on DimDate in SSMS, and specify this a name value for your datekey. Let me if that works.
ALTER TABLE [Dim].[Date] ADD AlternateDateFormat AS convert(date,[FullDate], 111);
When using SSIS in SQL Server 2005 to convert a FoxPro database to a SQL Server database, if the given FoxPro database has a date type, SSIS assumes it is an integer type. The only way to convert it to a dateTime type is to manually select this type. However, that is not practical to do for over 100 tables.
Thus, I have been using a workaround in which I use DTS on SQL Server 2000 which converts it to a smallDateTime, then make a backup, then a restore into SQL Server 2005.
This workaround is starting to be a little annoying.
So, my question is: Is there anyway to setup SSIS so that whenever it encounters a date type to automatically assume it should be converted to a dateTime in SQL Server and apply that rule across the board?
Update
To be specific, if I use the import/export wizard in SSIS, I get the following error:
Column information for the source and the destination data could not be retrieved, or the data types of source columns were not mapped correctly to those available on the destination provider.
Followed by a list of a given table's date columns.
If I manually set each one to a dateTime, it imports fine.
But I do not wish to do this for a hundred tables.
You could make a small FoxPro program that will loop through your list of tables and write out a SQL INSERT INTO statement for each record to a .sql file which you could then open from or paste into SQL Management Studio and execute. You could then control the date formats that will work with SQL Server's date type fields.
Something similar could be done in c#.