Compare two datetime fields in power bi query - powerbi

I have column name as IsGreater.
This column is filled by comparing two fields of dates.
one is today's date and another is date field in text format ex: "12/1/2018 8:00:00 AM" in text format.
I need to compare these two dates and return true or false.
Thanks in advance.
I am trying
IsGreater = IF((FORMAT(TODAY(),"MM/DD/YYYY HH:MM:SS tt"))>
(FORMAT([date],"MM/DD/YYYY HH:MM:SS tt")),true,false)
and
IsGreater = IF((FORMAT(TODAY(),"MM/DD/YYYY HH:MM:SS tt"))>
(FORMAT([date],"MM/DD/YYYY HH:MM:SS tt")),True(),False())
It's not working as assumed.
Need in help.
expected to be true as the date field contains "12/1/2018 8:00:00 AM" which is past.

Just reorder DD and MM:
= IF((FORMAT(TODAY(),"DD/MM/YYYY HH:MM:SS tt"))>
(FORMAT([Date],"DD/MM/YYYY HH:MM:SS tt")),true,false)

Related

PowerBi: Extract month from dd/mm/yyyy hh:mm:ss issue

I am trying to extract month from CreateDate field whose values are in dd/mm/yyyy hh:mm:ss format.
Expecting Nov to be present for the all 4 rows in the Column field but power bi considers date number as the month field and gives the incorrect values
The date format of your Createdate is English (United States) while you expect it to be English (United Kingdom). The type conversion should've been done properly in the PowerQuery editor "Using locale ..."*

Change string "dd/mm/yy HH:mm:ss" into accepted date/time format

I have a very rare date format dd/mm/yy HH:mm:ss that reads in as a string and I want to transform it into a date/time format PowerBI will accept. I managed to change the format into "dd/mm/yyyy HH:mm:ss", but now I have to switch the day part with the month.
How can I do this or is there an easier solution to my problem?
Select the column of date_time and change the data type from column tools to Date/time(pic 1) and after that select the format(pic 2) from column tools
pic_1
pic_2

Extracting day in a new field from a date in Pentaho

I have a field with a date in yyyy-MM-dd format, I want to extract the day only, for example, if the date is 2014-01-25, I want to have "25" in a new field. I used step "Calculator" is calculation "day of month of date A" but I get 1970-01-01 01:00:00 for all records.
Could someone tell me what might be the reason?
Before you actually have the Calculator step, have a Select Values step and make sure the date field is Date by explicitly giving the Date data type and specify the format it is currently in.

Changing format from time to data time format in SAS

Currently , I have date column in time format ,I want to change it to date time stamp format I.e ( I want the date column to look like 12nov 2020 12:03:45:00 )
Could someone help me on this ?
According to #KurtBremser:
SAS dates are counts of days, SAS datetimes are counts of seconds.
datetime = dhms(date,0,0,0);
will convert a date to a datetime. Or multiply by 86400.
A column showing a time representation hh:mm:ss can be one of three things:
A character column type containing digit characters 0-9 and :
A number column type containing a SAS time value being displayed as hh:mm:ss with the time format TIME8.
A number column type containing a SAS datetime value being displayed as hh:mm:ss with the datetime format TOD.
This sample program demonstrates how different kinds of values can all look the same when viewed.
data have;
v1 = '12:34:56';
v2 = hms(12,34,56);
v3 = dhms(today(),12,34,56);
put v1= / v2= time8. / v3=tod. / v3=datetime18.;
run;
------ LOG ------
v1=12:34:56
v2=12:34:56
v3=12:34:56
v3=25NOV20:12:34:56
Only #3 has enough information in the raw value to be formatted as ddmmmyyy:hh:mm:ss
format myDate datetime18.;
#2 requires computing a new value assuming something about the date part
* supposing myDate contains only time values (00:00:00 to 23:59:59) for today;
myNewDate = dhms(today(),0,0,0) + myDate;
format myNewDate datetime18.;
#1 requires interpretation through INPUT and a date assumption
* supposing myDate contains "hh:mm:ss" for today
myNewDate = dhms(today(),0,0,0) + input(myDate,time8.);
format myNewDate datetime18.;

Excel unable to subtract dates in "dd/mm/yyyy hh:mm" format

I have 2 adjacent columns in excel, each having dates in "dd/mm/yyyy hh:mm" format. But when I try to subtract them in the third column, it is unable to give me a numerical value, instead it shows the text "#value!" in the cell. How do I get the time difference between the 2 dates -
Answered behalf of Scott Craner
Then the "Dates" are text and not true Dates. You will need to convert them to true dates. My guess is that your local settings are mm/dd/yyyy not dd/mm/yyyy and as such Excel does not see them as dates
Check below link to know more.
https://www.ablebits.com/office-addins-blog/2015/03/26/excel-convert-text-date/