SQL converting dates in macro Answered

David Erkelius

Hi, 

I would like to compare two dates in stringformat. One is from GETDATE:

@STORE52 = SQL(SELECT CONVERT(VARCHAR(10), GETDATE() +2, 120));

Works fine.

the other is from DocDueDate:

@STORE14 = SQL('SELECT TOP 1 T1.[DocDueDate] FROM OCRD T0 INNER JOIN ORDR T1 ON T0.CardCode = T1.CardCode WHERE T1.[DocStatus] = 'O' AND T0.CardCode = $[$4.0.0] ORDER BY T1.[DocDueDate] DESC')

Works fine

 

Then i want to convert @STORE14 to textstring, but I cant get it to work

@STORE60 =SQL('SELECT CONVERT(varchar(10), @STORE14, 120') 

Doesnt work. What have I made wrong?

Best regards

/David 

 

Comments

2 comments

  • Comment author
    John Slaats

    Hi,

    I'm a newbe with B1Up but can it be that there is a parenthesis missing in the @STORE60 query?

    Also I understand that the @STORE variables are of type nvarchar.
    So your @STORE14 is already converted.

    If you need a specific conversion (date_style) you put it in the first query.

    Regards,
    John

    0
  • Comment author
    Yaremi Miranda Lopez

    Hello John,

    Thank you so much for your reply, you're correct! =)

    0

Please sign in to leave a comment.