VB - Fill cell background based on date comparing today to cell value - vba

I have a column that returns dates in this form:
"2016-06-01 23:29:34.283"
I am wondering how I can fill the cell background green if the day matches today, and red if its not today (hour and minute doesn't matter).
I tried this but no luck:
=Switch(Fields!Last_Upload.value = Today(), "Green", Fields!Last_Upload.value != Today(), "Red").
Edit: This is using VS Data Tools

Of course the problem is comparing the date without the timestamp. You can use the DateValue function for this like so:
=IIf(DateValue(Fields!Last_Upload.value) = Today, "Green", "Red")

Related

Conditional formatting a date range

I am trying to conditional format in SSRS.
in my report I have a planned start field and an actual start field.
I want the actual start field to change to red if the actual start date is more than an hour or less than an hour of the planned start date.
So if the planned start date is 25/07/2021 21:00 but the actual start date is 25/07/2021 22:00 then I want the actual start date to turn red.
Also if the planned start date is 25/07/2021 21:00 but the actual start date is 25/07/2021 20:00 then I want the actual start date to turn red.
can this be done?
This is what I have tried so far
=iif(DateDiff("H", Fields!ACTUAL_START_DATE.Value, Fields!PLANNED_START_DATE.Value) >= 1, "red", "black")
any help would be much appreciated
There are a variety of ways to handle this. Your method is fine, just need to add ABS() to your expression and it should work.
=iif(ABS(DateDiff("H", Parameters!actualstart.Value, Parameters!plannedstart.Value)) >= 1, "red", "black")

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

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.

Identify Week Number, Month Number, Year from DatePicker control in VBA userform

I have been trying to make my user form work by getting codes everywhere. I don't have any experience in VBA so the code that I have are patches from different sources.
I have a datepicker control in my user form and i'd like to get the corresponding week number, month number and year based on the date that is chosen from the datepicker control box and populate the corresponding textboxes for each
datepicker and textbox dependencies.
To get the week number use the below. The third and fourth arguments allow you to dictate the first day/first week of the year.
TextBoxWeek.Value = DatePart("ww", TextBoxDatePicker.Value, vbMonday, vbFirstJan1 )
Month:
TextBoxMonth.Value = format(TextBoxDatePicker.value,"mm")
Year: (you can also use "yy" to get the shorthand date eg. '17' rather than '2017')
TextBoxYear.Value = format(TextBoxDatePicker.value, "yyyy")

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)