I am using a Regular Expression for the date format (DD/MM/YYYY) validation.
If I have the training phrase as 22/05/2021 it works perfectly.
But I need to have the training phrase as 22/05/2021 sample#sample.com. When I use like that for the date it gives empty value as shown in the below image.
if I use #sys.date for the date field it not always gives the correct format I need.
As an example, if I need the value 3rd of June, 2021 and enter it as 03/06/2021, Dialogflow evaluates it as 2001-03-06 (6th of March, 2021). But I need it as 03/06/2021
The locale I have to use with my agent is English-en
Updated:
Not even for date validation, this is not working for any regular expression combined with email as in the below image.
I'm trying to use the CASE statement to output string values for an Event Label field using RegEx to produce a table that shows the number of events for each field value. So, if I'm looking for foobar, and other string values separately, within values for Event Label; it may either stand alone or be part of a URL like so:
|[object HTMLLabelElement] | Foobar |
/images/foobar-26.svg
It seems REGEXP_EXTRACT might suit this the best:
CASE WHEN REGEXP_EXTRACT(Event Label, '.(?i)foobar.') THEN Foobar
However, the table produced using the calculated field as the dimension only contains a blank row that seems to be the sum of the number of events.
What am I missing?
I think you need to use REGEXP_MATCH not REGEXP_EXTRACT, given your existing syntax, or to change the syntax to a straight REGEXP_EXTRACT without the CASE element.
I have a Google sheet which generates an error in the following expression:
=query(Capacity!A5:FE135,"SELECT C,A WHERE "&SUBSTITUTE(ADDRESS(1,match(D2,Capacity!A1:FE1,0)+2,4),"1","")&" = '"&C2&"' AND "&SUBSTITUTE(ADDRESS(1,match(D2,Capacity!A1:FE1,0),4),"1","")&" = 1 ORDER BY C")
for a single, specific input value (a date) at D2.
Essentially, the purpose of the code is to find the column location of the date at D2 in a second sheet (Capacity) and put the values of that column in that sheet into column C in the current sheet, while also selecting only rows that match on a second column. When the date is set to a specific value, however, the expression will not evaluate.
On breaking this massive expression down into its component parts, it turns out the problem is caused by this expression:
=SUBSTITUTE(ADDRESS(1,match(D2,Capacity!A1:FE1,0)+2,4),"1","")
which, for the offending date, is returning column BY.
This means the expression being evaluated in Google Visualization API query language is:
SELECT C,A WHERE BY = '' AND BW = 1 ORDER BY C
but the query language sees BY as a reserved word, not a column, and barfs.
How can I escape the column name somehow to make it clear that it is to be considered a column name?
The way is to surround the offending portion with back-quotes (as I used to make text monospaced here):
=query(Capacity!A5:FE135,"SELECT C,A WHERE `"&SUBSTITUTE(ADDRESS(1,match(D2,Capacity!A1:FE1,0)+2,4),"1","")&"` = '"&C2&"' AND `"&SUBSTITUTE(ADDRESS(1,match(D2,Capacity!A1:FE1,0),4),"1","")&"` = 1 ORDER BY C")
so the query will look like
SELECT C,A WHERE `BY` = '' AND `BW` = 1 ORDER BY C
I assume this will help when the sheet grows so big that we're on column IF as well.
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="...")
What is regular expression format for date dd-mm-yyyy.Following is the code i used but its not working.
[Required(ErrorMessage = "Activation date is required")]
[Display(Name = "Activation date")]
[RegularExpression(#"^([1-9]|0[1-9]|1[0-9]|2[0-9]|3[0-1])[- / .]([1-9]|0[1-9]|1[0-2])[- / .](1[9][0-9][0-9]|2[0][0-9][0-9])$", ErrorMessage = "Enter proper date")]
It would be very difficult to validate a date via regex. For instance, given 29-02-yyyy, how would you check if the given year is a leap year?
A better alternative would be to programatically use a validator. Check out how to use one here.
Another approach would be to use the DateTime.TryParse method. You can easily check the returned boolean value to see if you have a valid date or not.
try this regex
^(((((0[1-9])|(1\d)|(2[0-8]))-((0[1-9])|(1[0-2])))|((31-((0[13578])|(1[02])))|((29|30)-((0[1,3-9])|(1[0-2])))))-((20[0-9][0-9]))|(29-02-20(([02468][048])|([13579][26]))))$