Conditional formatting for current day date - reporting-services

I am just trying to getting my data to do a color fill if the date value equals today.
The data is coming from oracle:
=IIf(Fields!finishDATE.Value = Today(),"Yellow","Transparent")
This will not give me any errors nor will it do the function according to the expression. None of the data with the finish date equaling today highlights.
If today is 8/24/2021 it should look like this:
3/22/2021, 8/24/2021, 2/22/2021

As I'm not sure what format the data will come in from Oracle (I'm a MS SQL person) then this might be overkill but try this
=IIF (Format(Fields!finishDATE.Value, "yyyyMMdd") = Format(Today(), "yyyyMMdd"), "Yellow", Nothing)
All I'm doing here is comparing just the date parts of the date/datetime values.
Below is the output. The first column is the actual date column contents including a time, then for illustration only, the 2nd column shows it formatted to just the date part and the 3rd column show today() with the same format applied.
Finally, I used the keyword Nothing (SSRS almost equivalent of NULL) as this is the correct default value.

Related

How to highlight cell if date format is incorrect or blank?

I have an excel sheet with over 5000+ records.
I am trying to set the date column into correct format (dd/mm/yy)
Instead of visually looking at data to spot errors such as:
Blanks
Date inputted like this: 27//01/20 < notice the double //
Or something like this: 27/01/20.. < notice the full stops
Is there an easier way of finding errors in date column?
Here is a sample of my column A:
1st and 4th row should be marked in red, because it is not correct format.
Reason I want to achieve is this is because I am needing to import it into MySQL with correct column types. Not all to be varchar.
Use conditional formatting - choose rule type 'Use formula...', enter formula =NOT(ISNUMBER($A10)) for appropriate range and get red cells.

SSRS IIF expression giving only partial output

I have a simple IIF statement to say if the actual date is blank, show me TBC. Otherwise, show me what the actual date is. I can successfully get the TBC. But I cannot get the actual date to show where I know there is a date. Any help is appreciated.
=IIF(Fields!VPSR_Actual_Date.Value = "", "TBC", Fields!VPSR_Actual_Date.Value)
I'd do a check if the column is null or zero string and then format the date.
=IIF(IsNothing(CStr(Fields!VPSR_Actual_Date.Value)) OR CStr(Fields!VPSR_Actual_Date.Value) ="", "TBC", Format(Fields!VPSR_Actual_Date.Value, "dd-MMM-yyyy"))

How to check if a string contains a date?

I'm trying to iterate on a DataSet, this contain a results of query such as SELECT * FROM tb 1, now the first three field contains a date, the format saved in the database table is this:
yyyy-MM-dd HH:mm:ss
but the code return this:
yyyy/MM/dd HH:mm:ss
in particular this:
For z = 1 To ds.Tables(0).Columns.Count - 1
Console.WriteLine(ds.Tables(0).Rows(x)(z).ToString())
Next
So I need to recognize if the current string have this format: yyyy/MM/dd HH:mm:ss and parse it into: yyyy-MM-dd HH:mm:ss I tough to a regex pattern for recognize it, but I'm not an expert of regex. Anyway, if there is another solution I'll glad to see. Note that only the first three value and the last one of the table is date, the other values aren't date but contain integer or other string value.
Dates do not have a format. From MSDN:
Represents an instant in time, typically expressed as a date and time of day.
...
Time values are measured in 100-nanosecond units called ticks, and a particular date is the number of ticks since 12:00 midnight, January 1, 0001 A.D. (C.E.) in the GregorianCalendar calendar...For example, a ticks value of 31241376000000000L represents the date, Friday, January 01, 0100 12:00:00 midnight.
So, a DateTime is just a Big Number. Representing them as "dd/MM/yyyy" is part of the magic of the DateTime type. Part of the issue is this:
Console.WriteLine(ds.Tables(0).Rows(x)(z).ToString())
Row items are Object. It wont act like a DateTime type unless/until you get it into a DateTime variable. That print as a DateTime simple because the DataTable knows the underlying type; but it will use the default format for your Culture. This makes it look like dates have a built in format (or even that the "format changed" if you tried to set it to something), but you are a human and 635882810022222112L would not make sense to most of us.
To change the output style, you first need to get it into a DateTime variable. Apparently, a preliminary step is to determine if an arbitrary column is a Date. Rather than testing the "format" of the output, test the underlying data type. This does assume a proper DateTime column in the DataTable:
If ds.Tables(0).Columns(n).DataType = GetType(DateTime) Then
'...
End If
' Or:
If ds.Tables(0).Rows(x)(z).GetType Is GetType(DateTime) Then
'...
End If
Then to change the display, first get it into a DateTime variable:
Dim dt As DateTime
If ds.Tables(0).Rows(x)(z).GetType Is GetType(DateTime) Then
dt = Convert.ToDateTime(ds.Tables(0).Rows(x)(z))
' cant change "format" but you can change how it displays:
Console.WriteLine(dt.ToLongDateString)
Console.WriteLine(dt.ToString("yyyy-MM-dd HH:mm tt"))
Console.WriteLine(dt.ToString("dd MMM, yyyy"))
End If
An easier way to get and convert to DateTime is to use the Field(Of T) extension:
Dim dt = ds.Tables(0).Rows(x).Field(Of DateTime)(y)
when I peform the insert usually do this: Date.Now.ToString("yyyy-MM-dd HH:mm:ss") so I apply a format to date to insert... if I don't format correctly the date as I shown I get this value 0000-00-00 00:00:00
That doesn't apply a format to a date. It converts the DateTime to a string. While "yyyy-MM-dd HH:mm:ss" is the correct format to use when passing date data as a string to MySql, it is not needed. The MySQL Data provider knows how to convert a Net DateTime var to the data MySql needs/wants and back again -- that's its job.
' this will work fine
cmd.Parameters.Add("#SomeDate", MySqlDbType.DateTime).Value = myDateTimeVar
The format requirement you read about is the what you need to use in the MySql shell or WorkBench UI because you are entering text/string there...from the keyboard. It does not mean code must convert DateTime variables to string in a specific format for storing.
I ended up using this
Try
Dim theDate As DateTime = dr.Item(colName)
Return theDate
Catch
' do something
End Try
I would be happy to see a better method.
Based off of what you seem to be asking a simple replace would do
For z = 1 To ds.Tables(0).Columns.Count - 1
Console.WriteLine(ds.Tables(0).Rows(x)(z).ToString().Replace("/","-"))
Next
if it comes in with / they are changed to - if it comes in with - they remain intact.
Depending on the flexibility you want in this, it may be necessary to TryParse to ensure that the value you're working with is actually a valid datetime.

Conditional Formatting in Access wwith Dates

I'm having an issue with conditional formatting in Access where I need to format a value if the date occured before today and another field is blank. It works fine for most values, but for some reason when the day value is in the single digits of the current month, or you go two months ahead the value isn't read properly.
The Date on the left is referred to as [Plan_Date] and the column on the right is referred to as [Act_Date]. The premise is that if [Act_Date] is blank and [Plan_Date] occurs before today then the field should be highlighted. I'm using the expression:
[Act_Date]="" And [Plan_Date]<Date() in my conditional formatting.
The problem is that [Plan_Date] is being treated as a string and forcing an alphabetical order comparison between [Plan_Date] and Date(). The following strings are sorted in ascending alphabetical order:
11/15/2014
8/12/2014
8/25/2014
8/3/2014
You need to force [Plan_Date] to a date type for comparison purposes:
[Act_Date] = "" And CDate([Plan_Date]) < Date()

dd/mm/yyyy date format in SSRS

i'm trying to specify dd/mm/yyyy dateformat for date/time parameter in SSRS 2008 R2.
My computers datetime format is mm-dd-yyyy.
My requirement is, i want to show date format at dd/mm/yyyy irrespective of the system/server date format.
I've already tried CDate(Format(Today,"dd/mm/yyyy")) which didn't work. one very strange thing i observed is, it shows dd/mm/yyyy format only for dates on or before 12-MM-yyyy, and 13 onwards it gives error: Conversion from string '25-04-2014' to type Date is not valid. (Possibly it is trying to map 25(daypart) with MM-dd-yyyy (month part)) which is out of range of total months i.e. 12)
my research on internet says it is a bug in BIDS 2008.
What do i do to display date as dd/mm/yyyy ??
I don't have enough reputation to comment, but I did notice that you failed to put "()" after "Today". If I'm not mistaken you must put Today() for that function to work. Also, you might want to try putting CDate Around the Today() function. You shouldn't need it, but it's worth a shot. Also, for some odd reason, in my experience, you must capitalize MM for format to work correctly.
Like #Aditaya said, it should be =format(Today(),"dd/MM/yyyy")
The expression I usually use is:
=FormatDateTime(Fields!Date.Value, DateFormat.ShortDate)
However, this may be region specific.
Rather than writing an expression to do the formatting, you can also use the Textbox Format Property. But first you need to make sure that the data is in a date format. So use the CDate function on your column like this:
=CDate(Fields!Date.Value)
Then in the textbox properties go to the Number tab. Select Date for the category. Then you can select whichever format you want or use a Custom format. This will change how the column displays when you run the report.