Link to home
Start Free TrialLog in
Avatar of Trygve Thayer
Trygve ThayerFlag for United States of America

asked on

C# code If then else statement for date field.

I am a C# newby with a recently upgraded Epicor software and need some help.

I need some code to put in a query and have no clue how to write it.  In the ABL language I was used to it would be something like this

If IsNull(LaborHed.PayrollDate) then Today
else LaborHed.PayrollDate

In my own words I want to check if a date field is blank or null.  If it is blank or null then put in today's date otherwise use the date in the field.
Avatar of Juan Carlos
Juan Carlos
Flag of Peru image

if (LaborHed.PayrollDate == new DateTime()) { 
 return DateTime.Now;
}
else {
 return LaborHed.PayrollDate;
}

Open in new window


If type of LaborHed.PayrollDate is DateTime.
Avatar of Trygve Thayer

ASKER

This returns an error message of Possible SQL Injection.
ASKER CERTIFIED SOLUTION
Avatar of Rikin Shah
Rikin Shah
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial