Formatting google chart area date( like Mar 2012, Oct 2013 etc) - google-visualization

I want to show Google Chart Area date as Mar 2012, Oct 2013 etc. There should not be any date digits in the format. I can only find 3 formats as
formats
var formatter_long = new google.visualization.DateFormat({formatType: 'long'});
var formatter_medium = new google.visualization.DateFormat({formatType: 'medium'});
var formatter_short = new google.visualization.DateFormat({formatType: 'short'});
Resulting in to
February 28, 2008 (long)
Feb 28, 2008 (medium)
2/28/08 (short)
long and medium work for me if I can remove date digits from the result. Is there a chance to do it somehow?

Google uses a subset of the ICU SimpleDateFormat standard.
If you mean "remove date digits" as in "remove the day and display just month/year" then you could format the string as follows:
function drawVisualization() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
data.addColumn('date', 'Date');
data.addRows([
[new Date(2012,1,5)],
[new Date(2012,2,10)],
[new Date(2012,3,15)],
[new Date(2012,4,20)]
]);
alert(data.getFormattedValue(3,0));
var formatter1 = new google.visualization.DateFormat({pattern: 'yyyy, MMM'});
formatter1.format(data,0);
alert(data.getFormattedValue(3,0));
}
When you define the data table, the first alert will list the formatted date as "May 20, 2012". Once you apply the formatter, it will read "May, 2012" only. I think this is what you want. You can change the format as desired.

Related

Week number of year becomes 1 during the last week of the year

In this case, the output becomes 1 instead of 53 for the last week of the year, how can this be changed to show the proper week numbers?
struct ContentView: View {
#State var date = Date()
var weekFormatter: DateFormatter{
let formatter = DateFormatter()
formatter.dateFormat = "w"
return formatter
}
var body: some View {
VStack{
DatePicker(selection: $date, displayedComponents: .date, label: {Text("Bing")})
Text("\(date, formatter: weekFormatter)")
}
}
}
The meaning of the w character in the date format is described by Unicode Technical Standard #35 Part 4 ยง8.4. As of version 37, it says this:
8.4 Week of Year
Values calculated for the Week of Year field range from 1 to 53 for the Gregorian calendar (they may have different ranges for other calendars). Week 1 for a year is the first week that contains at least the specified minimum number of days from that year. Weeks between week 1 of one year and week 1 of the following year are numbered sequentially from 2 to 52 or 53 (if needed). For example, January 1, 1998 was a Thursday. If the first day of the week is MONDAY and the minimum days in a week is 4 (these are the values reflecting ISO 8601 and many national standards), then week 1 of 1998 starts on December 29, 1997, and ends on January 4, 1998. However, if the first day of the week is SUNDAY, then week 1 of 1998 starts on January 4, 1998, and ends on January 10, 1998. The first three days of 1998 are then part of week 53 of 1997.
Values are similarly calculated for the Week of Month.
So, if you want to change the way the weeks are numbered, you need to change the first day of the week, or the minimum days in a week, or both. You do that by creating a Calendar, setting the firstWeekday and minimumDaysInFirstWeek properties, and then assigning the Calendar to your DateFormatter's calendar property:
var calendar = Calendar(identifier: .gregorian)
calendar.firstWeekday = ...
calendar.minimumDaysInFirstWeek = ...
let formatter = DateFormatter()
formatter.calendar = calendar
formatter.dateFormat = "w"

Display last 12 months

I am lookking to display the last 12 months and the data for selected month. If a user selects december 2019, it will dsipaly all months from december 2018 till december 2019.
Example
Here is the pbix file https://drive.google.com/file/d/1WBOolZIFNTWQsPt_QvCY5OAmdy80lHzm/view?usp=drivesdk
Make sure that your Label_Month table is not connected to your fact table. Also, click on "Modeling" in the desktop editor and "Manage Relationships"; make sure that the filter value for Label_Month is not limiting your output table. Make sure that there is an actual date value being selected in Label_Month table; if there is not one add it. You will do the date limiting in the measure value that you aggregate. This measure assumes that you are summing, but you can use other operators in Calculate.
Measure = VAR StartDate = DATEADD(MAX(Label_Month(ActualDate)),-1,year) VAR EndDate = MAX(Label_Month(ActualDate)) RETURN
CALCULATE( SUM(Column), FILTER( ALL(Label_Month), Label_Month(ActualDate) >= StartDate && Label_Month(ActualDate) <= EndDate ) )

Google Charts Line graph displaying only first and last label

I have a line graph and the X-axis comprises of dates. what I want to do is that, my chart should display only the first-date and the last-date on the axis with sufficient gap in between to display the data related to the other dates (but NOT the label)
eg- http://i.stack.imgur.com/ujSRu.png
You need to set the hAxis.ticks option:
hAxis: {
// set the x-axis to show dates at each end, Oct 27 2013 - Nov 18 2013
// with no tick marks or labels in between
ticks: [new Date(2013, 9, 27), new Date(2013, 10, 18)]
}
If you know the exact amount of data entries, you may do:
hAxis: {showTextEvery: 4}

Convert email date into a datefield

I'm not sure if it's an ISO date or not. When I read email from a pop server, one of the fields is called "date", and it has a string that looks like this:
19 Jun 2012 18:02:09 -0400
Q: Is there a routine to convert this date to a ColdFusion date variable?
I created two variables.
thisdate = "19 Jun 2012 18:02:09 -0400";
thisdate = "19 Jun 2012 18:02:09";
I ran them through this conditional statement.
if (isDate(thisdate)) {
writeOutput("It is a date!");
} else {
writeOutput("It is NOT date!");
}
The first one is NOT a date. The second is a date.
Perhaps you could just look the "-0400", which is probably an offset.
You could manipulate the date to create the type of date that you really want.
newDate = dateFormat(thisdate, "full");
writeOutput(newDate);
newTime = timeFormat(thisdate, "full");
writeOutput(newTime);
You can try this UDF from cflib site

Coldfusion: Convert euro date to us date

I have a date picker sending string dates in Euro format, e.g. 02/12/2011 (December 2, 2011). However, when I try to prepare the date in US format so the database can deal with it, e.g.
dateformat(LSDateFormat(form.startDate),'yyyy-mm-dd')
or
dateformat(form.startDate,'yyyy-mm-dd')
it convolutes the date to 2011-02-12 (February 12, 2011).
Does anyone have a solution that can handle dates - either as strings or date objects.
Cheers,
Paul
How does this work for you:
<cfscript>
euDateArr = ListToArray(form.startDate, '/');
dateObj = CreateDate(euDateArr[3], euDateArr[2], euDateArr[1]);
</cfscript>