How to change Faker date format to yield date in "DD/MM/YYYY" format? - ruby

I am using Faker to generate a random Birthdate and feed the same in a Date input box in DD/MM/YYYY format through my automation script.
I tried this below snippet, however, it returns a date in YYYY/MM/DD format. I tried changing the from and to date format to DD/MM/YYYY as well, but no luck.
def self.get_birth_date
Faker::Date.between(from: '1950/01/01', to: '2001/12/31')
end
Would appreciate, if someone from the group can help. Thanks!

You could use strftime method:
Faker::Date.between(from: '1950/01/01', to: '2001/12/31').strftime("%d/%m/%Y")
It will return "29/05/1969"

Related

Compare a date column to today's date in dax im not getting the correct output as required

I have column datetimesent through which I will get to know that the schedule is gone for today, so I'm trying to write if else query where if datetimesent is today's date then schedule running else false.
My existing column is is in date format I need to compare it with inbuilt today/now function, but they are in datetime format, I'm not getting the output correct
You can use DATE() function to build date from your timestamp
for example:
DATE(YEAR([YourTimestampColumn]),MONTH([YourTimestampColumn]),DAY([YourTimestampColumn]))

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)

How to remove default date format from kendoui.min.js

I am using kendoui datepicker into inline grid,So i want to change default date format of min.js file . format like yyyy/mm/dd so please suggest me appropriate solution.
you can directly provide the format like
$('#datePicker').kendoDatepicker({
format: "yyyy/MM/dd"
});

Comparing dates in Xpath with different formats

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.

Ruby gem Mysql2 return date type cannot be parsed

I got the result in hash format:
"date"=>#'<'Date: 4911851/2,0,2299161>
Anyone know how to parse this format?
I'd like to parse it in to a ruby Date object and do further processing.
The result is still an timestamp object as far as I know. Just use it as it is inside an Date or DateTime to extract any data.
Alle the best.

Resources