I am trying to generate string dates in ISO 8601 format to feed to a program that downloads data from an external database. I have two versions of the code which generate inconsistent results. First
generates results like this:
which is as expected. But now a slight modification in the date display format
generates results as follows:
i.e. the values of the local variable are interpreted as year-month-day.
This is weird! Can anyone explain what is going on? In other circumstances the format %tdCY-N-D works properly to generate an ISO 8601 formatted string date.
Finally any other ideas on how I can get the local variable xdate to hold the string date "2024-04-01"?
Code:
local start_date=td(01apr2024) local end_date=td(15apr2024) forval date=`start_date'/`end_date' { local xdate: display %tdCYND `date' display "date: " %td `date' " xdate: " `xdate' }
Code:
date: 01apr2024 xdate: 20240401 date: 02apr2024 xdate: 20240402 date: 03apr2024 xdate: 20240403 date: 04apr2024 xdate: 20240404
Code:
local start_date=td(01apr2024) local end_date=td(15apr2024) forval date=`start_date'/`end_date' { local xdate: display %tdCY-N-D `date' display "date: " %td `date' " xdate: " `xdate' }
Code:
date: 01apr2024 xdate: 2019 date: 02apr2024 xdate: 2018 date: 03apr2024 xdate: 2017 date: 04apr2024 xdate: 2016
This is weird! Can anyone explain what is going on? In other circumstances the format %tdCY-N-D works properly to generate an ISO 8601 formatted string date.
Finally any other ideas on how I can get the local variable xdate to hold the string date "2024-04-01"?
Comment