0

I encountered a strange problem, moving from VS2015 to 2019. I've got a variable that is setup like this;

 SUBSTRING( (DT_STR,50, 1256)DATEADD("DAY",0,GETDATE()) , 1, 10)

This works perfectly in VS2015 but now when I tried to add the same code in a project, it returns "Cannot convert 'System.String' to 'System.DateTime'."

Does anyone know anything about this?

Tomas H
  • 57
  • 7

1 Answers1

0

You can use c#

DateTime.Now.ToString("MM/dd/yyyy");

This link has all versions:

https://www.c-sharpcorner.com/blogs/date-and-time-format-in-c-sharp-programming1

KeithL
  • 5,348
  • 3
  • 19
  • 25
  • Yes, but not in the expression builder. – Tomas H Jul 08 '20 at 11:54
  • It's a pain in the butt to write that out in an expression. That's why I gave you a simple script task to do it. You need to date part the heck out of getdate() to do it in an expression. – KeithL Jul 09 '20 at 01:46
  • ok, but the fact remains, why does it work perfectly in VS2015 and not in VS2019... – Tomas H Jul 09 '20 at 06:21
  • @KeithL, how do you parse it in a script expression to use as a variable in Expression Builder? – DataGirl Feb 25 '22 at 15:22