[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1330
  • Last Modified:

Argument 'DateValue' cannot be converted to type 'Date'.

Argument 'DateValue' cannot be converted to type 'Date'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Argument 'DateValue' cannot be converted to type 'Date'.

Source Error:


Line 8:        dim deletedate as string=""
Line 9:  
Line 10:       if appsettings.showlastdays>0 then deletedate=getdate(dateadd("d",-appsettings.showlastdays,todaydatetime))

 

dim deletedate as string=""
 
	if appsettings.showlastdays>0 then deletedate=getdate(dateadd("d",-appsettings.showlastdays,todaydatetime))

Open in new window

0
gianitoo
Asked:
gianitoo
  • 4
  • 3
1 Solution
 
sunithnairCommented:
Is todaysdatetime a datetime variable? Try this instead
Convert.ToDateTime(todaydatetime).AddDays(-appsettings.showlastdays).ToShortDateString()

Open in new window

0
 
gianitooAuthor Commented:
so it will be??
if appsettings.showlastdays>0 then deletedate=Convert.ToDateTime(todaydatetime).AddDays(-appsettings.showlastdays).ToShortDateString()
0
 
sunithnairCommented:
Yes
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
gianitooAuthor Commented:
i get this error
Exception Details: System.FormatException: String was not recognized as a valid DateTime.

dim deletedate as string=""

if appsettings.showlastdays>0 then deletedate=Convert.ToDateTime(todaydatetime).AddDays(-appsettings.showlastdays).ToShortDateString()
0
 
sunithnairCommented:
Can you tell me what is the value for todaysdatetime?
0
 
gianitooAuthor Commented:
has to be a datetime value.......
0
 
sunithnairCommented:
Yes I know if has to be a datetime value but can you tell me what is the value of it when you execute the code so that I can see what is wrong?
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now