How to Cast Date to String for Chart with Weekly Groupings in MS Access - sql

I have a simple Access application where I want a chart that shows groupings by weeks from daily records.
I have a query that converts the groups by the week and then displays the week as the first day like this:
WeekBegin: DateAdd("d",-(DatePart("w",[ScoreDate])-1),[ScoreDate])
Thsi gives the Sunday beginning the week correctly. The problem comes when I go to make a chart. The chart Row Source is
SELECT [WeekBegin],Sum([Scores]), (etc...) FROM [query] GROUP BY [WeekBegin];
When I do this the chart treats the bottom axis as a date value and each week is seven days apart making the bars tiny.
I'm sure the date format is the issue because when I make an integer out of the week value it formats how I want:
I can't figure out how to get it to show as a date like "mm/dd" but not treat it as a date and add all those blank days in between. I've tried messing with the axis settings but it doesn't seem to do anything.

Try casting the date as a varchar... use convert to get into whatever display format you want.

Related

Calculate date difference and return number of days

I need help to calculate the date difference and return number of days.
I used this in rtf template but it didnt work and when i hard code the dates it works!and not sure what is wrong with the data field.
UDRDAILYACTDATEDO this is variable,
UDRFCDDATEDO this is fixed date when the contract starts, and I need to calculate the cumulative days from first chargeable date FCD.
and when i try to calculate the days inside the data set in BI usining numtodsinterval it return the seconds along with the number and couldnt find a way to truncate it.

Qlikview Replace WeekSeq number with week number

I have a master calendar that includes week and weekseq, weekseq is just an autonumber of week and year. I am having an issue with the column labels on a 52 wk report that works of current week back 52 weeks. When i use weekseq as the column header it works out correctly but this header is of no use, Is there a way for me to replace weekseq with week in my column header? I have currently been trying =week(max(WeekSEQ)) for current week but not working out as it should.
Thanks
for sure :
=week(max(WeekSEQ))
is incorrect as WeekSeq is autonumber and week process date or timestamp field only.
So you need to have Date field in your calendar and use it:
=week(max(*date_field*))
(if you don't have date field you can create it but for that I need at least snapshot of your datamodel - you can make screenshot of table viewer which you can access using Ctrl+T)

Always Return the Previous Saturday's Date Using NOW Function in MS Excel 2007

I have a workbook that I am using the NOW function to return today's date and then I have another cell to convert to WEEKNUM that I use to MATCH on with a different tab. I need to be able to create a formula to read today's date and always return the previous Saturday. Example: Today is 6-8-2015. I want this formula to return 6-6-2015. Any ideas on how to make this work. I am struggling here.
How about:
=NOW()-(WEEKDAY(NOW(),1))
This will return the time 'now' minus the number of days from Saturday where Sunday = 1, Monday = 2 etc.
Note, this does include the timestamp along with the day (eg. 6/6/2015 14:48). If you want just the date you could daisy-chain a text function around it.

Format date in Values for a Range (Gant) Chart SSRS 2008 R2

I have a date column in which the dates are re-curring every year. I'm only interested in the month really, but I can't just put the month number as the high and low value for the gant chart. Is there any way I can format the column? Any suggestions would be awesome.
The gant chart currently is taking the whole date and is working fine, but like I said it goes out to the next year.
Figured it out. So the DATECOLUMN I had was formated as such:
Example: 2013-01-01 00:00:0.000
In order to put in the GANT(RANGE) CHART in the series property, under values, I formated the Top Value and Low Value as =MONTH(DATECOLUMN) using the expression option.
Then for the Horizontal Axis Properties I set the Interval to 1 and Interval Type to Number. And There you have it Monthly time spans with only the Months 1 - 12 showing.
I must also note that I only had one time recorded. So I just did Top Value as: DATEADD(MM,1,DATECOLUMN) In Order to get the right time span in my dataset Script.
Which date format would u like to display in your chart.
If (month with year) like 'Sep 2013'
use this date format for the same.
SUBSTRING(CONVERT(VARCHAR(11),getutcdate(), 113),4,8)

How to get month within a range vb2010

I just don't know how to go about this.
I designed a program that uses MS Access as its database. I have a field for month and year (the field data type is text) where user can register details. The program will register the month and year the user have chosen e.g month= September, year=2011.
My problem now is how to chose a range of data to view by the user using the month and year as a criteria e.g the User may want to view data range from (September 2011 to July 2013).
I couldn't figure out even how to try. Help will be highly appreciated.
Perhaps you could change your application logic to store the month and year as their respective numbers rather than text and change the field data types to numeric.
You could then construct a DateTime object from them, for example September would be 9 and you could use code like the following:
var startDate = new DateTime(year, month, 1); // get year and month as integers from database, uses the first as the date
var endDate = new DateTime(year, month, 10); // change the date but keeps the month and year the same
var endDate2 = startDate.AddMonths(1); // adds 1 month to the date
Alternatively, you could try using a calendar control to allow the user to select two dates instead of building it from a number of fields. Depending on what you are using this could be achieved a number of ways, for example in ASP.Net or WPF you could use two calendar controls and just use their SelectedDate properties as your range.
A range is from a startpoint until an end point. For the startpoint you can add automatically the first of Month. For the endpoint is it more complicated because there is no fix endpoint. What you can do is following:
Write an array that contains for each month the days (e.g. 30 or 31). Except for Febrauary there is a fix pattern.
for Febrauary use the selected year to check is the year a leap year or not. If not add 28, else add 29.
After that create the date string for your SQL:
Startdate 1.9.2011. Do for the entdate the same.
After that, I think you can use the keyword between in your SQL query.
You can assume that everything is entered on the first day of each month. I would pull the information using a query to the database.
select * from [tablename] where DateSerial([colYear], [colMonth], 1) between DateSerial([fromYear], [fromMonth], 1) and DateSerial([toYear], [toMonth], 1)
In this question are some ways to do this:
First. Filter the dates in a range assuming that you use a date like '07-12-2012'
i.e. September 2011 to July 2013
Where DateColumn > '09-01-2011' and DateColumn < '07-31-2013'
OR
Specify a Date and a Year
Where month(DateColumn)='1' and year(DateColumn)='2016'
Note:
There are many ways to do this.
You can Manipulate your statement depending on your desired output.