Converting number to date format using Power Query Editor - numbers

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.

Related

How to convert a field with 202008 to a date in Tableau

I am trying to convert a field that contains strings such as 202008, 202108 to a date field. I have tried the date() function, clicking on the measure and converting it to a date. I have also tried DATE(LEFT([Month],4)+"-"+RIGHT([Month],2)+"-01") but that will only return the year.
Using Tableau Desktop 2021.1, when I change the data type from String to Date, Tableau translates the strings to 8/1/2020 and 8/1/2021. If you are using an earlier version of Desktop, it is possible that this functionality is not present.
However, if changing the data type isn't working for you, the calculated field code you provided should actually work, you just need to change the date part from Year to Month/Day/Year using the Custom date part option.

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"})

Google Sheets - Date Format Display Issues

I'm currently building dashboards in Google Sheets and have run into a consistent issue with dates being displayed as a number opposed to a date format. EX: 43626 opposed to 6/11/19.
This data is being pulled from form sheet into a database, then queried into the dashboard spreadsheet where it is coming through as a number sequence opposed to readable date format. Currently have tried to use the DATEVALUE to reformat, as well as attempted to reformat the cell into a date format in both dashboard and database locations, with no luck.
//What I've tried
=TargetCell
43626
=DATEVALUE(TargetCell)
43626
=TargetCell //Reformatted as any Date format
43626
I was expecting the following
=DATEVALUE(TargetCell)
6/11/19
OR:
=TargetCell //Reformatted as any Date format
6/11/19
you got it wrong... function DATEVALUE creates 43626 from 6/11/2019
if you want to reverse it you need to use either:
internal custom date formatting (does not work all the times)
TEXT formula like: =TEXT(43626, "m/d/yy")
QUERY parameter format like: =QUERY(A:B, "format A 'm/d/yy'", 0)
or QUERY parameter toDate like: =QUERY(A:B, "toDate(A)", 0)
https://developers.google.com/chart/interactive/docs/querylanguage#top_of_page

DATE FORMATTING - COGNOS

I am using cognos version 10 and I need my dates to display in this format 'yyyy-mm' but it is showing dates like '2014-04' as '2014-4' so it is reading the dates out of order by producing '2014-11' first because it starts with a one. I need to add a zero to those double digit integers that way the months(specifically) will display in order.
here's an the code I've created in attempt:
_year( start_date ) ||'-'|| _month( start_date )
IF(_month(start_date) > 10)
THEN('0' +_month(start_date))
Short answer: Use yyyy-MM.
Your question lacks a lot of detail, so my response is based on considerable guess-work.
Are you asking about formatting, or do you want to transform the values? Formatting can be done without code. The code for your data item should be start_date.
Is this for a List column body? Where do you enter your format (yyyy-mm)? Are you using the Data format property?
In the Data format dialog, if you can't find another setting that will do what you want, you can enter a pattern into the Pattern property. If you look at the tips at the bottom of the Data format dialog, you'll notice that using yyyy-mm would give you a four digit year, a hyphen, and a two-digit minute. Perhaps you should try yyyy-MM. It works for me.
As for sorting: Even if you used yyyy-M for the pattern, 2014-04-22 (displayed as 2014-4), should sort before 2014-11-01 (displayed as 2014-11). The only reason the sort would be wrong is if it is using some other data besides the dates.

IBM i (AS400/ISeries) - Adding days to date field in WRKQRY

I have a decimal date field (TDDATR) that is in the YYYYMMDD format.
I would like to create a field that is TDDATR + 30 days but I am unable to.
Using 'Define Results Field' I have tried a few things;
Simply doing this;
TDDATR + 30 DAYS
But it returned this error: Labeled duration not used correctly.
I tried using the DIGITS and SUBSTR commands to create a field in the DDMMYYYY format and then +30 days but got the same error.
Same as above but in the DD/MM/YYYY format - same error.
Using DATE(TDDATR) but all I see is +'s in the field.
Using DATE( ) on the fields created in step 2 and 3 - still get +'s
I've ran out of ideas - any help would be greatly appreciated.
Query/400 lacks a lot of the features that an SQL based interface has.
I'd urge you to consider switching to Query Manager (STRQM) which is a fully SQL based product. You can even convert Query/400 queries to Query Manager queries with the RTVQMQRY command by having the ALWQRYDFN parm set to *YES.
The other option that IBM is pushing is Web Query. Again, fully SQL based and you can convert Query/400 queries into it.
Having said that, the problem is that FLD + 30 DAYS only works when FLD is a DATE data type. Query/400 includes a DATE() function to convert non-date types into date. But it's very limited in that it only works with character fields formatted according to your job defaults. Assuming you're in the US, it'd only work with a character value of '07/01/15'.
You could do a lot of manipulation in Query/400 and end up with a result field that meets DATE()'s requirements. But a better solution would be to create an SQL view over your table and have your numeric date converted into a date data type in the view.
You can find code examples that show how to convert a numeric YYYYMMDD to a actual date data type in the view. However, I'd recommend create a user defined function (UDF) that will do the conversion for you. That will make it much easier to use in the view and to reuse in other places.
If you'd like, there's an open source package called iDate, that includes all the code required for convert to/from date data types.
Download that, install/compile it and your SQL view becomes
select ... idate(TDDATR,'*CCYMD') as TD_DATE
from myfile
The use of days is as follow
Field Expression
CURDATE_30 days(current(date)) + 30
The solution to your problem is: given the field A dec(8,0)
Field Expression
YYYYMMDD_ date(substr(digits(a),5,2)||'/'||
substr(digits(a),7,2)||'/'||
substr(digits(a),3,2))
NEXT_MONTH DAYS(YYYYMMDD_) + 30
Remember to check the date format in your job description. In the example the format is MDY or MM/DD/YY.
More info here
Based on the information here, I created the below 2 fields;
TDDIGI DIGITS(TDDATR)
TDDAT1 SUBSTR(TDDIGI,7,2)||'/'||
SUBSTR(TDDIGI,5,2)||'/'||
SUBSTR(TDDIGI,3,2)
From here I was able to create a date field;
TDDAT2 DATE(TDDAT1)
Which allowed me to perform the necessary calculations.
The format of TDDAT1 is based on your job description which can be found by;
WRKJOB
Option 2
Page down
Date format..: X
Mine was *DMY, so TDDAT1 was formatted based on this.