Start a new topic

possible to format a date variable multiple ways in same query?

Hi, can we use a single ${mydate}$ variable but format it differently? It appears that if you try multiple format= strings in one query, DBVis ignores the earlier ones and applies the last format string to all instances of the variable.


In the query below, the error output shows that DBVis tried to apply the last specified format "MM" to all instances of "myotherdate"


select

    '2022-08-01',

    cast('20220801' as date),

    datefromparts(2022, 8, 1),

    {d '2022-08-01'},

    '${mydate}$',

    ${myotherdate||||date}$,

    cast('Aug 1, 2022' as varchar(20)),

    cast(${myotherdate||||date||format=[MMM dd, yyyy]}$ as varchar(20)),

    datefromparts(${myotherdate||||date||format=[yyyy]}$, ${myotherdate||||date||format=[MM]}$, 28)



Thank you.

1 Comment

Andy,


The format[] option can only be used with the pre-defined variables:


${dbvis-date}$
${dbvis-time}$ 
${dbvis-timestamp}$


Read more in: https://confluence.dbvis.com/display/UG/Using+DbVisualizer+Variables#UsingDbVisualizerVariables-Pre-definedVariables


Regards


Roger

Login or Signup to post a comment