Date values from an int and a string in separate columns - date

I have an issue where I'm trying to get a date value out of 2 columns. One has int values in the '2017" format and the other has 'April' as the 2nd. How can I combine them to create a "2017-04-0000" date?
Thanks

Your best option is to use the dateparse formula. That way you can combine your separate fields and create a new datestamp.
Create the calculated field as follows, note here I have made the day the 1st of the month you could change this to suite your purpose:
dateparse('ddMMMMyyyy', '01'+[Manufacture Month]+str([Manufactured year]))
Find out more here

Related

Is there a way to pull just the Year out a VARCHAR datetime value?

I am working on a project, in Snowflake, that requires me to combine pest & weather data tables, but the opposing tables do not share a common column. My solution has been to create a view that extracts the year from the Pest Table dates, format ex.
CREATION_DATE: 03/26/2020 09:11:15 PM,
to match the YEAR column in the Weather tables, format ex.
DATEYEAR: 2021.
However, I have come to find that the dates in the pest report are VARCHAR as opposed to traditional date/datetime values. Is there a way to pull just the Year out the VARCHAR date value? Additional information: I cannot change the tables themselves, I will need to create a view that preserves all other columns and adds a new "DATEYEAR" column.
Yes , we can and below is working example:
create table test (dt string );
insert into test(dt) values ('01/04/2022');
Select dt, DATE_PART( year, dt::date) from test
To make it easy, you can split the string into an array and take the third member of the array (using 2 since arrays are 0 based):
select strtok_to_array('03/26/2020', '/')[2]::int as MY_YEAR;

Converting number to date format using Power Query Editor

I need help to convert Numbers into date format using Power Query Editor in either Excel or PowerBI
The date appears in number form like this 930101 and I want to convert it to normal Uk date format
Not sure which one is month and which one is date among "0101" in your string. But you can handle this your self and follow this below steps for get your required output in Power Query Editor-
First, split your string value using fixed 2 character and your data will be divide into 3 column now. define which one is Year, Month and Day.
Now, merge those 3 column maintain the UK pattern DD/MM/YY using a separator "/" and you will get a string like "01/01/93".
Finally, create a custom column using the below code-
Date.From([Merged],"en-GB")
Here is the final output-
In the above image, you can see the date in still US format just because of my Laptop's locally setup.

DAX and FORMAT function

i have a field for date with date, month and year.In my visualization, I need date to be displayed in (MON-Year) format.
I switched to data view, created calculated column with
Mon-Year = FORMAT('table'[Date],"YYYY-MM")
Now it's getting displayed as (YEAR and Month number) but I want to change it as month name.
After changes in data view, when I close apply, the column is present but there is no data type visible.
Should I create different calculated fields for year and month separately and then concatenate it?
any help would be appreciated.
If you want month first, then maybe you should specify it that way.
Mon-Year = FORMAT('table'[Date],"MMM-YYYY")
This may be useful for you:
https://learn.microsoft.com/en-us/dax/custom-date-and-time-formats-for-the-format-function

How to convert a specific text string to today's date in Power BI

I have a table with a column called that contains text. Most of the values are years. However, some have the value "present" to represent groups that are still currently active. I want to convert those values to today's year, and convert the column type to date (specifically year type). I want to avoid creating a new column if possible.
Please see below for the DAX language that worked.
= Table.ReplaceValue(#"Extracted Year2",null,DateTime.LocalNow() ,Replacer.ReplaceValue,{"Disbanded"})

translating value of a column of a spread sheet with google app script

I have a spreadsheet that has a column with date formatted data (see here).
However, when i get the values with (sheet previously defined):
var array = sheet.getDataRange().getValues();
and i try to get dates from the dates column,
var date = array[somerow][Column_dates];
i got a number like: 42905.15239780092 (for first row with date, that is supposed to be a today date).
But if i use (new Date()).getTime() i got something like: 1497907218972.
Both are completely different....?
What i would like to do is compare both dates....
What's wrong?
Regards,
Someone else will probably be able to provide a better explanation but I think:
The number 42905.15239780092 is a date time format.
The number 1497907218972 is a time format.
JavaScript Date Objects
i found a workaroud, that is using getDisplayValues() instead of getValues() to get the array. This give me a date string on the column with dates that it is easier to work with...