Comparing dates in Xpath with different formats - xpath

I have a date in this format "21-Mar-2014"
I already tried to search for Xpath formulas but with no use
I am getting the first format 21-Mar-2014 using SeleniumIDE and want to check if this value is the date of today,
So how can xpath generate today's date and compare it for the date extracted using Selenium

You can parse the string into a date with an xpath function such as date:date(string) (described in this question).
Today's date already in xml date format is supplied by fn:current-date() (see here)

You can get the value, sore it in a variable, and then compare it. Eg:
storeText //xpath/goes/here myDate
storeEval (new Date(storedVars['myDate']) > new Date()) isAfterToday
Note, the storedVars array holds all the variables.
new Date should parse most formats, otherwise you can use any javascript in the storeEval stage to reformat it.

Related

Convert azure.timestamp to NiFi date data type in NiFi expression language

I am using the NiFi ListAzureBlobStorage to get the available blob objects. The processor creates a flowfile for each object with the attributes containing the object metadata. I want to filter on the azure.timestamp attribute, but I do not know what the numeric value represents and how it relates to the NiFi's expression language date data type. I want to compare it with a known date so I need to convert it to a NiFi data-time variable first. How do I do this?
Thanks
According to the code it is already in "NiFi format" which means a Unix timestamp.
Since it represents the number of milliseconds passed since 1/1/1970, you can compare this and the other timestamp using regular number comparison operators.
example: ${azure.timestamp:ge(${now()})} - this will return true if the azure.timestamp is later(or equal) than the current timestamp(now).
If you'd like to compare it to another attribute you can do this:
${azure.timestamp:ge(${attribute.name})}.
If you'd like to convert a different date into a unix timestamp, you can use toDate and then toNumber, or to do the other way around, just use format.

CDate can't convert from string dd/MM/yyyyy in Report

06/07/2559 < this is dd/MM/yyyy
This is ok for converting but CDate convert to this format MM/dd/yyyy
If I use this
30/06/2559 I'll get error because CDate think 30 is a month.
Anyway to convert my string dd/MM/yyyy to Date in Report?
Thanks in advance
Three ways/things that you can do to achieve this -
You can set the localisation format at the report level which means you don't have to use the format function every time you drop a date on to the report.
You can covert the string to your required format ('mm/dd/yyyy' or 'dd/mm/yyyy') in database itself. For your reference in MSSQL you can do it like this -
You can format (use FORMAT() function) your code in SSRS itself somewhat like below -
On that field change attibute Language to es-Es (or any other country that uses dd/MM/yyyy format)

Filter by time and date in Hadoop

I have a table of data which have date and time as two separate field where date format is
dd/mm/yyyy and dd-mm-yyyy and time format is like hh:mm:ss(eg: 6:52:53)
i need to filter the record for a particular time period that both time and date wise filtering.
is there any predefined filter available with hive or pig?
Hive does recognize certain strings as unixtime dates.
You might try a where condition while concatenating the time & date together into unixtime format.
Some documentation on Hive date functions/formats are located here: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-DateFunctions
I suppose you have one column having two date format ie. dd/mm/yyyy and dd-mm-yyyy
What You can try
1) Replacing '/' to '-' so that complete column will be in dd-mm-yyyy format.
2) Try concatanating this field with time field
3) filter it by Casting concatinated field.
Hope this helps.
just possibility :- Have you tried casting that concatenated field to date datatype and then try date functions for desired output ?
eg. to_date()
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF

How to find a date and time stamp in a file using VBscript?

I have an online temperature logger that publishes the date and time of last measurement in a file.
I need to find the date and time stamp in the html file using VBscript, and then check if it's older then 2 hours comparing to current time.
Example date format: 12.04.2013 16:45
You could extract the timestamp with a regular expression
\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}
However, due to the characteristics of HTML this is prone to error (line-wrapping, inline tags, …), so a better approach would be to extract the date from the HTML using DOM methods (e.g. getElementsByTagName().
Once you have the date string, you can use the DateDiff function to calculate the difference to the current timestamp:
DateDiff("h", datestring, Now)

How to format birt date report parameter?

By default if the input parameter to BIRT report is of type Date, it takes yyyy-MM-dd format.
Can we change to something else e.g. may be dd/MM/yyyy ?
You can change the input format for a date parameter. Click on "Change..." select Format as "Custom" and you can enter a valid format code as you like.
If you want to enter a default Date you still have to use the yyyy-MM-dd Format, this cannot be changed ( where I used new Date() in the Picture), but the output format will still be your entered format.
Another option is to use the format Date Time section in the Birt designer and choose the right locale and formatting for the date.
I have done it in Birt 3.7 and works fine
There can be many way to do that but the easy one is you can do this in SQL Query itself.
If you are using DB2 you may try
VARCHAR_FORMAT("Your Column Mapping Name",'DD-Mon-YYYY') AS dataSetName.
But this will change its Data type to String
Try if this make any seance.

Resources