Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


Eddie Kumar
2017-12-19T12:26:31Z
Hi,
What's the best way to convert a date-string (date written as string) into a date-object, in SQL we can do this using PARSE or CAST functions, e.g. CAST('20120822' AS DATE), what's the equivalent of this in VisualCron please.

Basically, I need to pass a custom date (e.g. 17-12-2016) to a Stored Procedure, I don't want to pass today's date using "{DATEFORMAT(yyyyMMdd)}" nor want to use DateAdd() etc.
TIA
Eddie
Sponsor
Forum information
thomas
2017-12-20T11:04:03Z
I have never figured out how to do this in vc either. It's tricky since you have to guess the returntypes of the functions. DateFormat returns a string I guess so that won't work.

This works: Sql server accepts format 'yyyy-MM-dd' by default. So just pass in eg 2017-12-20 as parameter to the proc and it will work.
Support
2017-12-20T11:05:18Z
You should pass yyyy-MM-dd as Thomas say unless your SQL server has different regional settings.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
thomas
2017-12-20T11:13:37Z
As a sidenote, this is a slightly confusing topic in Sql server (to me anyway). I believe yyyy-MM-dd and yyyyMMdd are considered 'safe' formats. So they should both work

https://dba.stackexchang...uage-and-dateformat-safe 

Eddie Kumar
2017-12-20T12:19:31Z
Hi Thomas (and Support),

Thanks for quick replies, really appreciate it.

As you have rightly said, passing in the date written as string literals works in both the "yyyy-MM-dd" and "yyyyMMdd" formats, but no other date-format is accepted (not even dd/MM/yyyy even though the default language set in our database is "English".)

For some reason it's not accepting: {DATENOWADD(Days|3|dd/MM/yyyy)}, which I thought should work - but doesn't matter as the literal values work fine.

Thanks
Support
2017-12-20T12:52:12Z
Originally Posted by: Eddie Kumar 

Hi Tomas (and Support),

Thanks for quick replies, really appreciate it.

As you have rightly said, passing in the date written as string literals works in both the "yyyy-MM-dd" and "yyyyMMdd" formats, but no other date-format is accepted (not even dd/MM/yyyy even though the default language set in our database is British English.)

For some reason it's not accepting: {DATENOWADD(Days|3|dd/MM/yyyy)}, which I thought should work - but doesn't matter as the literal values work fine.

Thanks



I assume format dd/MM/yyyy is not working in SQL Management studio either so it comes down to what your particular SQL server supports in terms of format.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Eddie Kumar
2017-12-22T10:03:43Z
Yes, that's correct. To ensure that British date format (DD/MM/YYYY) is accepted, we updated the Default Language in SQL Server to "British English" (at Server level). As Default Language also controls the date-format, it resolved the issue.

Thanks.
Scroll to Top