I have a client in Germany using an SSRS report and the date parameter is showing "OKT" instead we need it to be "OCT" for october
Is there a setting to make sure GETDATE() is already converted or will a convert function work?
here is my error:
library!ReportServer_0-45!1554!10/15/2018-10:23:17:: i INFO:
RenderForNewSession('/Finance/MC Dashboard')
processing!ReportServer_0-45!10bc!10/15/2018-10:23:17:: e ERROR:
Throwing
Microsoft.ReportingServices.ReportProcessing.ReportProcessingException:
,
Microsoft.ReportingServices.ReportProcessing.ReportProcessingException:
Query execution failed for dataset 'JournalEntries'. --->
Microsoft.AnalysisServices.AdomdClient.AdomdErrorResponseException:
Query (5, 39) Cannot convert value 'Okt 14, 2018' of type Text to type
Date. at
Microsoft.AnalysisServices.AdomdClient.AdomdConnection.XmlaClientProvider.Microsoft.AnalysisServices.AdomdClient.IExecuteProvider.ExecuteTabular(CommandBehavior
behavior, ICommandContentProvider contentProvider,
AdomdPropertyCollection commandProperties, IDataParameterCollection
parameters)
Since the GetDate is coming through in German from the server, then the SQL CONVERT function should also use German to convert it to a date.
CONVERT(DATETIME, GETDATE(), 106)
If you do get an error, you might need to set the language first (SET Language German;) - though that would be wonky that one SQL function would work in German but the other doesn't.
just capture the data first in a text box and check its format. Depending on how it looks you can worse case convert this receive input param to internal varchar and then just get the date part out. i.e.
declare #internal_param as varchar(15);
set #internal_param = #Input_dateParam --your variable name here
--select logic here
Related
I'm using Hive at the moment. I have a column (column A) of strings which is in the following format 11/9/2009 0:00:00. I'd like to extract the yyyymm. i.e. I'd like the above string to be 200909. I've tried two different methods none of them worked.
I have tried to convert the string using two different methods
concat(year(Column A),lpad(month(Column A),2,0))
convert(datetime, Column A)
For the first row of code I'm receiving : NULL in all rows
For the second one I'm receiving :
Encountered: DATETIME Expected: ALL, CASE, CAST, DEFAULT, DISTINCT,
EXISTS, FALSE, IF, INTERVAL, NOT, NULL, REPLACE, TRUNCATE, TRUE,
IDENTIFIER CAUSED BY: Exception: Syntax error
Use unix_timestamp(string date, string pattern) to convert given date format to seconds passed from 1970-01-01. Then use from_unixtime() to convert to required format:
select from_unixtime(unix_timestamp( '11/9/2009 0:00:00','dd/MM/yyyy HH:mm:ss'), 'yyyyMM');
Result:
200909
Read also: Impala data and time functions and Hive date functions.
One more solution, works in Hive:
select concat(regexp_extract('11/9/2009 0:00:00','(\\d{1,2})/(\\d{1,2})/(\\d{4})',3),lpad(regexp_extract('11/9/2009 0:00:00','(\\d{1,2})/(\\d{1,2})/(\\d{4})',2),2,0))
Since I'm trying to turn strings into YYYYMM I have to use the below, which worked for me:
'concat(substr(Column A, instr(Column A, ' ')-4, 4),substr(Column A, instr(Column A, ' /')+1, 2))'
What's the most direct way get an interval from a string (varchar) value in postgres?
I have a column that contains JSON data. One of the JSON properties is a "runtime" value that is formatted like: "runtime":"03s.684". Using the JSON functions I'll able to get to just the runtime value with no problem, but then I've got the quoted string value.
I was looking for something similar to to_timestamp() so I could parse the string doing something like:
select to_interval('"03s.684"', '"SS\s.MS"'); --would like to do / this function doesn't exist
or something like this would be nice too:
select to_timestamp('"03s.684"', '"SS\s.MS"') :: interval; --also not valid
One approach I can see that should work is to translate the string into a format that can be cast to interval using regexp_replace() but that doesn't seem like the best approach. What's the recommended way of getting an interval from a custom-formatted time string?
You can use to_number()
SELECT to_number('3s.684', '999D9099') * '1 second'::interval;
I want to create a categorical variable based upon date and input the following code.
data temppricedata;
set SASHELP.PRICEDATA;
date_group='';
IF (date>='MAR2002'd) THEN
date_group='new';
IF (date<'MAR2002'd) THEN
date_group='old';
run;
However I got error like
ERROR: Invalid date/time/datetime constant 'MAR2002'd.
ERROR 77-185: Invalid number conversion on 'MAR2002'd.
I am sure the format follows sas date format which is MONYY.
I do not know how to correct this.
As #Jeff mentioned, the correct way for specifying SAS date constants is DDMONYY or DDMONYYYY.
data temppricedata;
set SASHELP.PRICEDATA;
length date_group $3.;
IF date >= '01MAR2002'd THEN date_group='new';
ELSE IF date < '01MAR2002'd THEN date_group='old';
run;
How do I format a date to put it in a factory_girl_rails factory eg:
Factory.define(:profile) do |t|
t.length 110
t.shipdate 1993-04-06
end
If it matters, I'm using postgresql and factory_girl_rails 1.0. The error I've been getting is ActiveRecord::StatementInvalid: PGError: ERROR: invalid input syntax for type date: "1982" The rails version is 3.1
You're missing the quotes around your date string:
Factory.define(:profile) do |t|
t.length 110
t.shipdate '1993-04-06'
end
1993 minus 4 is 1989, 1989 minus 6 is 1983. Are you sure you copied the error message correctly?
The error message tells us, that you tried to write the string '1982' to a date field, which is obviously not valid. A date needs a month and a day, too.
If you keep having input of that sort, you could process it with to_date(), which can make sense of it:
SELECT to_date('1982', 'YYYY-MM-DD')
Result:
1982-01-01
There are a couple of settings that influence processing of date/time values, most importantly DateStyle. An explicit cast with to_date() works independently, though.
This is copied ditto from example given in Sql2008 R2 doc - Syntax: DATENAME (datepart ,date )
SELECT DATENAME(datepart,'2007-10-30 12:15:32.1234567 +05:10')
And it throws
Msg 155, Level 15, State 1, Line 4
'datepart' is not a recognized datename option.
What is wrong here ? Where is Bill...
You should specify what part of the date you want in the place of datepart parameter.
Check this link:
http://msdn.microsoft.com/en-us/library/ms174420.aspx
So in case you need year part of the date it would be:
SELECT DATENAME(year,'2007-10-30 12:15:32.1234567 +05:10')
What is wrong here?
This is not supposed to be copied and run.
You should substitute datepart with any of the valid options given under the example your copied (year, quarter, month etc).
Where is Bill...
http://en.wikipedia.org/wiki/Bill_Gates%27_house
My local BOL with the same link is quite clear what a "datepart" is
Note: some DATENAME calls return numbers for Far Eastern languages
Also note that DATENAME will return data as a varchar datatype. Use DATEPART function which retunrs data as integer datatype
SELECT DATEPART(year,'2007-10-30 12:15:32.1234567 +05:10')