BookmarkSubscribeRSS Feed
Pandu2
Obsidian | Level 7
Hi All,
Can anyone help me on how to convert today's date time to ISO 8601. Which is like YYYY-MM-DDTHH:MM:SS.000Z format.
Any help is appreciated.
Thanks.
13 REPLIES 13
Pandu2
Obsidian | Level 7
I didn't have any date time value stored. I need to take the daily wise system date to convert it to YYYY-MM-DDTHH:MM:SS.000Z.
Thanks.
Pandu2
Obsidian | Level 7
Hi All,
I've got some api url named https://xyz.com/abc/def/expecteddel<YYYY-MM-DDTHH:MM:SS.000Z;status==1001

So over there YYYY-MM-DDTHH:MM:SS.000Z should be daily wise datetime and that datetime and status==1001 must be used as macro variable to create a url. For ex,
%let host= rest.xyz.com;
%let uri=/abc/def;
%let date must be equal to YYYY-MM-DDTHH:MM:SS.000Z; to this format.
%let status must be equal to ==1001.
So the final url looks like this.

%let url=&host.&uri.&date.&status.;
So, can anyone help me out on how to achieve the above url macro variable please. Any help appreciated.
Thanks.
Pandu2
Obsidian | Level 7
It's my bad the api url is https://xyz com/abc/def/?filters=expecteddel<YYYY-MM-DDTHH:MM:SS.000Z;status==1001

The must be converted into a macro variable as shown above ex
Kurt_Bremser
Super User
%let host= rest.xyz.com;
%let uri=/abc/def;
%let date = %sysfunc(datetime(),e8601dt24.3)Z;
%let status = status==1001;

%let everything=https://&host.&uri./?filters=expecteddel<&date.%str(;)&status;

%put "&everything";

Log:

 69         %let host= rest.xyz.com;
 70         %let uri=/abc/def;
 71         %let date = %sysfunc(datetime(),e8601dt24.3)Z;
 72         %let status = status==1001;
 73         
 74         %let everything=https://&host.&uri./?filters=expecteddel<&date.%str(;)&status;
 75         
 76         %put "&everything";
 "https://rest.xyz.com/abc/def/?filters=expecteddel<2021-11-18T09:07:54.382Z;status==1001"
Pandu2
Obsidian | Level 7
Thanks, Everything looks good but the isn't converted to that format 2021-11-18T09:07:54.382Z
Log :
"https://rest.xyz.com/abc/def/?filters=expecteddel<1952863053.113Z;status==1001"
This is how it printed the url.
Pandu2
Obsidian | Level 7
Date isn't converted
Kurt_Bremser
Super User

As you can see from the log that I posted, the code works (tested on SAS On Demand, so no special setup).

Post your complete log of these macro statements as you ran them.

Pandu2
Obsidian | Level 7
Here's the log:
1 The SAS System 01:33 Thursday, Nov
NOTE: Writing HTML5(EGHTML) Body file: EGHTML
23
24 %let host=rest.xyz.com;
25 %let uri=/abc/def;
26 %let date = %sysfunc(datetime(),e8061dt24.3)Z;
27 %let status= status==1001;
28 %let url=https://&host.&uri./?filters=expecteddel<&date.%str(;)&status;
29 %put "&url";
"https://rest.xyz.com/abc/def/?filters=expecteddel<1952863053.113Z;status==1001"
Pandu2
Obsidian | Level 7
I ran it in Sas EG
Pandu2
Obsidian | Level 7
I'm sorry my bad, I can't be thankful enough for your assistance.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 13 replies
  • 1808 views
  • 1 like
  • 2 in conversation