How to assertion the Dates - selenium

I am trying to Assert the 2 dates value and getting failed as
org.opentest4j.AssertionFailedError:
expected: "2022-08-17"
but was: "2022-08-17 00:00:00"
i used the below code
Assertions.assertThat(appointmentDate).isEqualTo(Resappdate);

The dates you are comparing should be in the same format.
In order to compare these date objects you need to transform the first date into the format of the second date or vise versa.

Related

If function on two differently formatted date/datetime variable in SQL/SAS

I have a dataset with two date columns (Conversion Date, click_date) that are formatted differently (Conversion Date: ymdhms., click_date: date9.)
What I want to do is create an If/Case When statement in my script that compares the two dates, and if the dates are the same I want it to add 1 day to the Conversion Date. Here is a sample:
So in this case we can see that 10/28/2022 matches with click_date in the 2nd row, this should show as "10/29/2022 02:03:49" in the output
Found a way using the intnx function. Here is the line of code I used:
if click_date = datepart("Conversion Date"n) then "conversion date"n=intnx('dtday', "conversion date"n, 1, 'same');
else "Conversion Date"n = "Conversion Date"n;

Convert Date to formatted date

I have a column for dates and the values are like this 1181202 and i want to convert it to normal date format "02-12-2018" so i can compare it with another date however when i am trying the following it returning wrong year and date
SELECT CONVERT(Datetime, Text_UPD_DATE,106) -- i have tried all numbers
From Notes
it's returning 5134-01-09 00:00:00.000
Can you please advise on the correct command
At a total guess, based on your one example:
CONVERT(date,'20'+STUFF(Text_UPD_DATE,1,1,''),112)

Comparing a date and getting result of records having further dates

I am using sql for database connectivity. I am filtering records in database on date basis using sql query which consists of function convert(varchar(100),column name,106). I am comparing it with date having dd/MMM/yyyy format. As a result I get records of next all the dates.
Example: If I try to filter the table by 01/June/2017 then inspite of having records of that date, I get records of next all the dates. I am not able to get records of 01/June/2017.
I have used greater than or equal to expression.
It is better to convert it to this yyyymmdd number format and do the comparison as below:
select convert(int,convert(varchar(10),[your column],112))
20170529
Don't convert your dates into any format (=strings) when doing comparison. Always use the date (or datetime etc) format. That way you will be comparing the actual values, not string or numeric comparison. Here the problem is that format 106 is dd mon yyyy so it will never match your date because it's a string dd/MMM/yyyy but you will get any dates starting with 02 anyhow, for example 02/Jan/1990, because in alphabetical order that will come after your given date.

Incrementing a date in openrefine

I have a date in format of YYYY-MM-DDThh:mm:ss
Please provide a GREL expression that increments date to 1 month from the present date value for all cells in the column in openrefine. Thanks!
First you need to make sure the data in the cells is of type 'date' - if the text in the cell is in green then the data is already 'date' type. Otherwise you will need to convert it using the GREL:
value.toDate()
Screenshot - before converting to date
Screenshot - after converting to date
Once you have the data as Date type, then you can use the following GREL to increment by one month:
value.inc(1,'month')
For more on using dates in OpenRefine see https://github.com/OpenRefine/OpenRefine/wiki/GREL-Date-Functions

Oracle Date format - Strange behaviour

I am writing a SQL query to retrieve data from a table between two dates. I give two inputs as shown. I convert the Date TO_CHAR(DD/MON/YYYY).
1. StartDate > 01/SEP/2009
EndDate < 01/OCT/2009
2. StartDate > 01/SEP/2009
EndDate < 1/OCT/2009
I don't get any result for the first input. When I change it to second one, I get the result.
What is the difference between 01/OCT/2009 & 1/OCT/2009 ?
when comparing dates you should always convert explicitely both sides of the operator to DATE datatype. Assuming StartDate and EndDate are both DATE datatype, this would work:
StartDate > to_date('01/SEP/2009', 'dd/MON/yyyy')
AND EndDate < to_date('01/OCT/2009', 'dd/MON/yyyy')
In your case however the result you get is consistent with VARCHAR comparison. You're comparing strings and it's VERY unlikely you will get the correct result (since months are NOT sorted alphabetically for instance).
If StartDate and EndDate are indeed VARCHAR you should convert them explicitely:
to_date(StartDate, 'dd/MON/yyyy') > to_date('01/SEP/2009', 'dd/MON/yyyy')
AND to_date(EndDate, 'dd/MON/yyyy') < to_date('01/OCT/2009', 'dd/MON/yyyy')
This is valid for all versions of Oracle.
Since I don't have an Oracle client available to verify my answer, it's not certain but: In Oracle, a single digit in the date string representing the day (D) is used to specify the day of week (Monday-Sunday), while 2 digits are used to specify the day of month (3 digits will represent the day in the year). Although you mentioned you're converting the string using what seems like the right way to do the interpretation, I think this could be the source of the problem (or at least could be an explanation to the difference..).