Freemarker check for date/time - templates

Below is the two lines of code that throws error:
<#assign test2="20:56:20"?time("HH:mm:ss")>
${test2?date}
The second line ends up with error:
freemarker.template.TemplateException: Cannot convert TIME into DATE
I know this is expected. But how can I check, if a date variable has got the 'date' value before displaying it on screen? For ex: In above example, i would like to check if 'test2' contains a date part before diplaying it on screen.

This is how i usually do it:
dateIssued?datetime("MM/dd/yyyy hh:mm a")
or
dateIssued?datetime("hh:mm a")
or
dateIssued?datetime("MM/dd/yyyy")
Just make sure you passing into your model java.util.Date
So I just use the datetime all the time. Hope this will help you.

Related

Creating a Custom Column from CurrentDate

I'm trying to create a new custom column from a conditional statement and current date.
Next picture explains exactly what i need to get with power query.
An example of what I need from pseudocode is:
if [fecha fin de plazo]>=CurrentDate and [fecha CIERRE investigación]=null
then "string"
My biggest problem is I don't know how to extract the current date with PowerQuery.
You could try using,
if [fecha fin de plazo]>= DateTime.LocalNow() and [fecha CIERRE investigación]=null
then "string"
DateTime.LocalNow()
Using the DateTime.LocalNow you get the date and time of your system, the problem is at time to compareting the date value with the result of DateTime.LocalNow() becsause you need to compare only dates.
That's why It must use DateTime.Date. This fucntion returns the date component of DateTime.LocalNow().
if [date1] >= DateTime.Date(DateTime.LocalNow()) and [date2]=null
then "string"
You can get more information about this functions here:
DateTime.LocalNow()DateTime.Date()

Date comparison in power bi dax

I had a problem with my code. It returns the below error:
DAX comparison operates do not support comparing values of type date with values of type text.
Basically, I want to count rows based on some conditions. And I know there is a need to convert the data type, but I am not sure how to do it.
Total Open Issues =
--------------------
--basic info
VAR SELECTEDDATE =
DATEVALUE(SELECTEDVALUE(Calender[FullDateAlternateKey].[Date]))
--------------------
--FIND the relvent data
VAR rlvttable =
calculatetable(
Tracker,
Tracker[Catagory]="ISSUE",
DATEVALUE(Tracker[ClosedDate])>SELECTEDDATE
||Tracker[ClosedDate]=""
)
--------------------
--Results
Return
countrows(rlvttable)
Anyone could advise me how to correct it? Thanks~
Check the data type of columns Tracker[ClosedDate] and Calender[FullDateAlternateKey] - one of them is Text, rather than Date.
To fix, you could:
choose a different field which is already a Date format
change the format of the offending column
use DATEVALUE in your measure, to convert the text date to a real date.
It also looks like you need to edit this statement, as these conditions conflict:
Tracker[ClosedDate]>SELECTEDDATE
&&Tracker[ClosedDate]=""
I am trying to compare the closedDate with "". I should use blank() instead.

RPA(blueprism) date validation

I am trying to validate date which is coming from an excel sheet , the format should be in dd/mm/yyyy
i tried with regex pattern [0-9]{2}/[0-9]{2}/[0-9]{4}
but this won't work with single digit date and we since we cannot add 0 at start in excel sheet this pattern ain't working. (this is for blueprism tool which have a action for regex matching]
To build in the resiliency you require, you'll have to accept either 1 or 2 digits for both dd and mm:
[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}
Since you are mentioning that you are working with BluePrism, are you sure that you really need Regex for validating dates? Because BP has built-in feature for that callable directly inside a Calc stage - checkout following example (you can see Expression of selected Calc stage in top Expression bar).
The function used for validating dates is IsDate([Some date as string]), result is saved into a Flag data-item.
After the check you can use that Flag data-item in a Decision block and do whatever you consider appropriate if a date is not an actual date.
Note: of course, if you are working with lists/datatables in a Code stage instead of iterating over a collection in process layout, then you need something else, but this might be still helpful.
In Code stage I would probably simply use DateTime.Parse(String) method which is able to automatically convert a date in a form of a String into a DateTime object instance; example:
' DateTime.Parse throws an Exception if parsing failed.
Dim valid As Boolean = False
Try
Dim d = DateTime.Parse(First_Date)
valid = True
Catch e As Exception
valid = False
End Try
See more about parsing dates using DateTime.Parse at MSDN: https://msdn.microsoft.com/en-us/library/1k1skd40(v=vs.110).aspx
There is also a nice post about parsing dates here: https://stackoverflow.com/a/18465222/7439802
In blue prism you can use
FormatDate(Now(), FormatOfDate)
For comparing two dates, initially Convert(" FormatDate ") in same format and then you can compare.
For " FormatDate " option you can refer Help of Blue prism and search for dateadd --> select the Calculation and decision

Sitecore date comparison doesn't return expected results

I'm trying to return a list of courses using an iqueryable query but am having issues with some date comparisons.
I'm currently using the code
query = query.Where(r => r.EndDate >= DateTime.UtcNow);
which returns courses with dates in the future, however it will not return courses that end on the same day with a time ending later than the time returned by DateTime.UtcNow.
Any ideas what I am doing wrong?
I've just used Luke to check the index and if I use
end_date:[20170531t092205609z TO *]
I get back the exact results I need, however in the logs the actual query uses
+end_date:[20170531t092205609z TO *] +_template:a84b75fccac64eafa746f4b71e628adc - Filter :
I then get more results back including the course I was missing.
a) Why do I get more results back using the second query?
b) Why is it that in my C# code the results returned do not match the search results?
Had a similar issue and described our solution here: https://ggullentops.blogspot.be/2015/12/sitecore-lucene-index-and-datetime.html.
Our problems had 2 reasons:
The first reason is that Sitecore stores its DateTimes in UTC (which was an hour difference with our local time)
Second reason was that Sitecore uses "t" in the dates as lowercase in the query. In my index however they are all uppercase. If I try the query with Luke it does give me the wrong results indeed.. When I alter the query in Luke to use uppercase T it works correctly..
The easiest solution we found was a format attribute in the index config:
<field fieldName="datefrom" storageType="YES" indexType="UNTOKENIZED" vectorType="NO" boost="1f"
format="yyyyMMdd" type="System.DateTime"
settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider"/>
(note the format="...")

Converting time stamp in informatica to date

I want to display the time stamp in following format '2011-04-22 10:41:57.000' to date as '04/22/2011' but when it convert it to following form TO_DATE(TO_CHAR(Date), 'MM/DD/YYYY HH24:MI:SS') it is displaying as null.
I am planning to use substring after the conversion
Can someone please tell me where i am going wrong?
You can simply do TO_CHAR(Date, 'MM/DD/YYYY')
i used 'TO_DATE(TO_CHAR(Date), 'MM/DD/YYYY HH24:MI:SS')' and later 'SUBSTR(Date_V,1,11)' and i got required output