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')
Related
I am using Tableau Server version 10.4.3
I have a dimension rTime which has string value. the entries in rTime is of like this
May 10, 2019 8:59:56.303 PM UTC
I want to check whether the rTime is today or not. I cannot use DateParse since my server doesn't have this functionality.
I created a calculated field CheckrTime with below content :
STR(LEFT(SPLIT([rTime],':',1),LEN(SPLIT([rTime],':',1))-2))
When I am dragging CheckrTime into workspace area, the output is coming in below format which is what I wanted :
May 10, 2019
When I am checking ISDATE("May 10, 2019") (a normal string), it is outputting TRUE as expected but when I am checking ISDATE(CheckrTime) it is outputting FALSE . Why?
The reason I am checking above thing is I am looking to use DATEDIFF function of tableau in this way:
DATEDIFF('day', DATE(CheckrTime), TODAY()) == 0
NOTE
If someone is wondering ,I have taken care of the level of granularity.
If you have a better solution then the one I am following, please do tell me.
This is working for me. I would expect May 10 <> May 16 (today) and therefore return false. However, when I change your example to today's date it does in fact come back as true.
You could also try this formula for the date LEFT([rTime],FINDNTH([rTime],' ',3)). It is slightly less complicated but will give you the same answer.
Calculated field (date type) depends the locale used which defines date format. Are you able to use Date function?
In Tableau website there is a example using english locale
For string 06May2017
DATE (LEFT([Original Date], 2) + "/" + MID([Original Date],3,3) + "/" + RIGHT([Original Date],4))
Above mentioned highligts / character between digits which is depending on locale
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
I want to ask how can I sort my chart by month (etc: Jan, Feb, Marc, Apr, ...) using Power BI?
I had try to put this:
CalendarInv = CALENDAR ('KPI', 'KPI[Month]'), today())
but it give me a pop up error:
"The function MINX takes an argument that evaluates to numbers or dates and cannot work with values of type String."
Thank you in advance.
You haven't provided any repro or dummy data, or given any context to the formulas you posted, so I'm going to focus on the main question: how to sort by month.
First up: make sure your source column is of type Date! If it is a string, do a conversion in the query, model, or a new derived column, and work from there.
I'm assuming that you fixed that, and that you have something similar to this dummy data:
InvoiceDate;Value
2017-09-01;200
2017-09-16;300
2017-10-01;250
2017-11-01;230
2017-09-25;150
Now, there are several derived columns I suggest for easy month-based sorting:
MonthNr = MONTH([InvoiceDate])
MonthNrWithName = FORMAT([InvoiceDate]; "MM (mmm)")
YearMonth1 = YEAR([InvoiceDate]) & "-" & IF(MONTH([InvoiceDate])<10;"0";"") & MONTH([InvoiceDate])
YearMonth2 = FORMAT([InvoiceDate]; "yyyy-MM")
Here's what they look like in graphs:
I personally prefer option 4, usually.
I am trying to get a date from its integer components: I have day, month and year as variables (that can change, I don't want to hard code them), and I want to reunite them in a date variable.
For example, something like that;
myDay: 15
myMonth: 4
myYear: 2016
`date$(myYear,myMonth,myDay) --> should return 2016.4.15 (formatted as a date).
Any way to do that?
Thank you
q)d:3
q)m:8
q)y:2016
q)"D"$"." sv string (y;m;d)
2016.08.03
See cast vs tok - need to use different arguments depending on if what you're casting from is a string or not
I have a report that takes a date as a parameter.
If I use =Parameters!Date.Value, the report runs fine.
However, if I use =DateAdd("d", 1, Parameters!Date.Value), the report is left blank, even though the formats are exactly the same:. (Note: it simply cannot run. It's not that there are no values to return as the field names don't return either.)
I have also tried =DateAdd(DateInterval.Date, 1, Parameters!Date.Value)
=DateAdd("d", 1, Parameters!Date.Value)
=DateValue(FormatDateTime(DateAdd("d", 1, Parameters!Date.Value), DateFormat.ShortDate )) and many variations thereof but I can't seem to crack it!
Update
If I use DateInterval.Month instead of DateInterval.Day then the date is still incremented as desired (12/22/2010) but the table shows up! Interesting how my local settings are dd-mm-yyyy and these dates are mm-dd-yyyy.
Try changing the locale of the report to EN-GB (I'm assuming you're in the UK), as the report might be getting confused between different date formats.