Tableau Convert Date to first date of the month - tableau-desktop

How can I convert any date to first of the month in tableau while retaining month as 2 digits and
format as date?
I have tried
INT("01" + "-" + STR(MONTH([Date])) + "-" + STR(YEAR(Date))) which returns month as single digit
Date
Converted Date
9/01/2020
1/01/2020
10/01/2020
1/01/2020
5/03/2021
1/03/2021
12/03/2021
1/03/2021

You can create a calculated field like this:
MAKEDATE(YEAR([Date]),MONTH([Date]),1)
If you're using a live connection, it all depends on the source you're connecting to.
You can also try:
date(
right('0'+str(month([Order Date])),2)
+
'01'
+
str(year([Order Date]))
)
Just remember to right-click your CF --> Default Properties --> Date Format
You should get something like this:

Related

How to print the correct date in google sheet using Keyboard shortcuts?

Hi everyone,
I want to print the current timestamp in google sheet. I'm using keyboard shortcut Ctrl + Shift + ; to print the current time. The timestamp is correct but when I change the format of the timestamp to date and time, the date is actually incorrect because the date is on 30 Dec 1899 as shown in the screenshot above.
There is another shortcut key which is Ctrl + Alt + Shift + ; which print the correct date and time but I don't prefer to use this as I don't want the output to show the date. May I know is there any way for me to change the date from 30 Dec 1899 to current date when I'm using Ctrl + Shift + ;?
Any help will be greatly appreciated!
It is a common practice to store dates in databases as a number of days elapsed since 1st January 1900. If the date part of the timedate object is unknown (meaning that only the time parts are known), then it is assumed to be 30th December 1899 (one day before 1st January 1900) by agreement.
In the given example you create a timedate object based on the current time, so the date part is left blank. After that, if you try to format that object as a full date, then the date part is assumed to be 30th December 1899 because it is unknown.
In conclusion, you should use Ctrl + Alt + Shift + ; if you want to work with both dates and times; or Ctrl + Shift + ; if you only need times (but keep in mind that it has a unknown associated date that will be represented as 30th December 1899 if formatted properly). Additionally you could use Apps Script to develop Sheet macros that create datetime objects fitting your precise needs. Don't hesitate to leave a comment if you need further explanations.

get the next date based on frequency set using google sheet formula

I need to display the upcomind date based on the start date and frequency set.
I have tried with
=TODAY() + MOD(TODAY() - C2, F2)
Here is the sheet
Could try:
G2 + F$2-MOD(G2 - C$2, F$2)
where G2 is today's date
Answer:
The upcoming date is given by:
=((((((C2-DATE(1970,1,1))*86400)+(((D2-DATE(1970,1,1))*86400)-((C2-DATE(1970,1,1))*86400))/H2)/60)/60)/24)+DATE(1970,1,1)
This is equivalent to:
(end date) - (start date)
(start date) + ___________________________
(frequency)
Where each date is converted to a unix timestamp for calculation and converted back to date format for display.
Remember that frequency will have to be decremented when each upcoming date passes in order to update the formula to the new upcoming date.
References:
DATE - Docs Editors Help
Unix Time - Wikipedia

regarding writing expression in derived column ssis

I have a date column called duedate, i need to make a new column which is called originaldate.
originaldate column should have dates as - duedate column dates + 90 days.
So, i need to add 90 days to a date column.
Can you please hep me with the expression for adding 90 days to a date column.
The syntax for this is:
DATEADD(datepart, number, date)
So for you, it would be:
DATEADD("day", 90, duedate)

Timezone Offset in Angular JS and Rails

Background: I'm building an app with Angular JS as web interface and Rails API. The problem I am having is passing a date from Angular to Rails.
Issue: I have a form with a Date of Birth date field, when a user inputs his DOB say March 1st, 1985, Angular interprets it as 1985-03-01 00:00 +0800 (if you're in Hong Kong or Singapore) and sends a request to Rails. The first thing Rails does with it is to convert it to UTC, which means the datetime is now 1985-02-28 16:00 UTC. Therefore, when the date is saved to the database date column, it becomes Feb 28, 1985.
Solution for now: What I'm doing now is on Angular side, I get the Timezone offset hours and add it to the date, so instead of 1985-03-01 00:00 +0800, it is now 1985-03-01 08:00 +0800. When Rails get it, it converts to 1985-03-01 00:00 UTC and so saves the correct date to db. However, I believe this is a better alternative to tackle this issue.
Thinking about parsing just the date in Rails, yet the params[:dob] I see is already UTC by the time I get it. Would love to know if there is a better practice than my current solution. Thank you for any comment and feedback.
This problem is actually quite common, and stems from two separate but related issues:
The JavaScript Date object is misnamed. It's really a date + time object.
The JavaScript Date object always takes on the characteristics of the time zone for the environment in which it is running in.
For a date-only value like date-of-birth, the best solution to this problem is to not send a full timestamp to your server. Send just the date portion instead.
First, add 12 hours to the time, to use noon instead of midnight. This is to avoid issues with daylight saving time in time zones like Brazil, where the transition occurs right at midnight. (Otherwise, you may run into edge cases where the DOB comes out a day early.)
Then output the date portion of the value, as a string in ISO format (YYYY-MM-DD).
Example:
var dt = // whatever Date object you get from the control
dt.setHours(dt.getHours() + 12); // adjust to noon
var pad = function(n) { return (n < 10 ? '0' : '') + n; }
var dob = dt.getFullYear() + '-' + pad(dt.getMonth()+1) + '-' + pad(dt.getDate());
Another common way to do this is:
var dt = // whatever Date object you get from the control
dt.setHours(dt.getHours() + 12); // adjust to noon
dt.setMinutes(dt.getMinutes() - dt.getTimezoneOffset()); // adjust for the time zone
var dob = dt.toISOString().substring(0,10); // just get the date portion
On the Rails side of things, use a Date object instead of a DateTime. Unlike JavaScript, the Rails Date object is a date-only object - which is perfect for a date-of-birth.

It is possible to change or disable Date validator in jira

I change calendar javascript to Hijri, But another problem comes up. It seems that a class (DueDateValidator.class) try to validate input date, while the number of days in month is different to georgian calendar. for example we have 31 days in second month of year but in georgian (february) it is 28 or 29.
I don't think there is an out-of-the-box option to cancel Jira's date validation. You could overwrite Jira's date validation, but I think it will be easier to use a Free Text Field custom field that will hold the date as a string. Then, add to the field js code that will hide this field and copy it's date to the date field.
To keep the right order when searching for issues, you can either use date mapping to keep the georgian calendar up to date, or store the dates in a sortable way (for example YYYY/MM/DD/HH/MM - 201302161334) and order the results according to this field.
UPDATE
Simple example for Jira version 5.2.6, this will copy the text from field id customfield_10001 to the created field:
AJS.$("#create-date").text(AJS.$("#customfield_10001-val").text().trim())
To search easily keep another text field and save the date in the following format :
year month day hour minute
All in digits. for example, today's Gregorian date would be:
2013 02 267 10 26
than, when searching for issues, for example to find issues created after today's date:
custom_filed > "2013 02 267 10 26"
that sorting will work since it will sort issues first by year, than month, day, hour, minute.
I stored date in text field by creating new custom field in system-customfieldtypes-plugin.xml filed but In search it only accept exact text not > or <
custom_filed ~ "2013 02 267 10 26" It is acceptable but
custom_filed > "2013 02 267 10 26" shows jQL error.

Resources