Question Paul Riker · Nov 16, 2017 SQL Convert yyyymmdd string to mm/dd/yyyy #SQL #Caché Any suggestions on the most efficient way to convert yyyymmdd string to mm/dd/yyyy? 0 0 11,684
Paul Riker · Nov 16, 2017 Is there a better approach than this?select convert(varchar(20),cast ('19770110' as datetime),101) Arun Kumar · Nov 16, 2017 Please try this Cache Object script command.w $ZD($ZDATEH("YYYYMMDD",5))Example:w $ZD($ZDATEH("20170925",5)).Output: 09/25/2017 Evgeny Shvarov · Nov 16, 2017 This is beautiful! Gerd Nachtsheim · Nov 17, 2017 Funny, I learnt a similar approach by the numbers many moons ago.USER>w $tr("12/34/5678",56781234,20171116)11/16/2017 Robert Cemper · Nov 17, 2017 much faster and straight forward string conversion then $ZD* stuff doing unnecessary conversions . Kyle Baxter · Nov 16, 2017 The correct way to do this is with TO_DATE:select TO_DATE('19850720','YYYYMMDD')That will convert the text in the first argument (a string) using the format in the second parameter into a date, which will be displayed using the current selectmode. Try this in the Management Portal. Alexander Koblov · Nov 16, 2017 select $Translate('Mm/Dd/YEAR','YEARMmDd','20171116') Log in or sign up Log in or create a new account to continue Log inSign up Log in or sign up Log in or create a new account to continue Log inSign up Log in or sign up Log in or create a new account to continue Log inSign up
Arun Kumar · Nov 16, 2017 Please try this Cache Object script command.w $ZD($ZDATEH("YYYYMMDD",5))Example:w $ZD($ZDATEH("20170925",5)).Output: 09/25/2017 Evgeny Shvarov · Nov 16, 2017 This is beautiful! Gerd Nachtsheim · Nov 17, 2017 Funny, I learnt a similar approach by the numbers many moons ago.USER>w $tr("12/34/5678",56781234,20171116)11/16/2017 Robert Cemper · Nov 17, 2017 much faster and straight forward string conversion then $ZD* stuff doing unnecessary conversions . Kyle Baxter · Nov 16, 2017 The correct way to do this is with TO_DATE:select TO_DATE('19850720','YYYYMMDD')That will convert the text in the first argument (a string) using the format in the second parameter into a date, which will be displayed using the current selectmode. Try this in the Management Portal. Alexander Koblov · Nov 16, 2017 select $Translate('Mm/Dd/YEAR','YEARMmDd','20171116')
Evgeny Shvarov · Nov 16, 2017 This is beautiful! Gerd Nachtsheim · Nov 17, 2017 Funny, I learnt a similar approach by the numbers many moons ago.USER>w $tr("12/34/5678",56781234,20171116)11/16/2017 Robert Cemper · Nov 17, 2017 much faster and straight forward string conversion then $ZD* stuff doing unnecessary conversions . Kyle Baxter · Nov 16, 2017 The correct way to do this is with TO_DATE:select TO_DATE('19850720','YYYYMMDD')That will convert the text in the first argument (a string) using the format in the second parameter into a date, which will be displayed using the current selectmode. Try this in the Management Portal. Alexander Koblov · Nov 16, 2017 select $Translate('Mm/Dd/YEAR','YEARMmDd','20171116')
Gerd Nachtsheim · Nov 17, 2017 Funny, I learnt a similar approach by the numbers many moons ago.USER>w $tr("12/34/5678",56781234,20171116)11/16/2017 Robert Cemper · Nov 17, 2017 much faster and straight forward string conversion then $ZD* stuff doing unnecessary conversions . Kyle Baxter · Nov 16, 2017 The correct way to do this is with TO_DATE:select TO_DATE('19850720','YYYYMMDD')That will convert the text in the first argument (a string) using the format in the second parameter into a date, which will be displayed using the current selectmode. Try this in the Management Portal. Alexander Koblov · Nov 16, 2017 select $Translate('Mm/Dd/YEAR','YEARMmDd','20171116')
Robert Cemper · Nov 17, 2017 much faster and straight forward string conversion then $ZD* stuff doing unnecessary conversions . Kyle Baxter · Nov 16, 2017 The correct way to do this is with TO_DATE:select TO_DATE('19850720','YYYYMMDD')That will convert the text in the first argument (a string) using the format in the second parameter into a date, which will be displayed using the current selectmode. Try this in the Management Portal. Alexander Koblov · Nov 16, 2017 select $Translate('Mm/Dd/YEAR','YEARMmDd','20171116')
Kyle Baxter · Nov 16, 2017 The correct way to do this is with TO_DATE:select TO_DATE('19850720','YYYYMMDD')That will convert the text in the first argument (a string) using the format in the second parameter into a date, which will be displayed using the current selectmode. Try this in the Management Portal. Alexander Koblov · Nov 16, 2017 select $Translate('Mm/Dd/YEAR','YEARMmDd','20171116')
Is there a better approach than this?
select convert(varchar(20),cast ('19770110' as datetime),101)
Please try this Cache Object script command.
w $ZD($ZDATEH("YYYYMMDD",5))
Example:
w $ZD($ZDATEH("20170925",5)).
Output: 09/25/2017
This is beautiful!
Funny, I learnt a similar approach by the numbers many moons ago.
USER>w $tr("12/34/5678",56781234,20171116)
11/16/2017
much faster and straight forward string conversion then $ZD* stuff doing unnecessary conversions .


The correct way to do this is with TO_DATE:
select TO_DATE('19850720','YYYYMMDD')
That will convert the text in the first argument (a string) using the format in the second parameter into a date, which will be displayed using the current selectmode. Try this in the Management Portal.
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue